Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Download Specific Commit Gitlab _BEST_

3 views
Skip to first unread message

Delores Mertine

unread,
Jan 25, 2024, 6:24:08 PMJan 25
to
<div>I'm fairely new to git.</div><div></div><div>While working on a project on Gitlab, I made some changes in the development branch(green colored branch) instead of checking out a new branch from the development, making changes in the new branch and then merging it back to the development.</div><div></div><div>Meanwhile, one of the other developers took a pull from the development branch and started working on it(ARE-1195). Now, I know this is going to create a lot of merge conflicts when the developer will try to merge his branch into the development branch.How can I avoid this? I tried looking for a possible solution and came across two terms, revert and reset but i'm confused between these.</div><div></div><div>I want to revert my repository back to the commit where the other developer created ARE-1195 but still keep the changes I made after that.</div><div></div><div>Posting the latest git graph snippet for reference.</div><div></div><div></div><div>Each uppercase letter here, A through G, stands in for a commit, just as each colored dot in the original image stands in for a commit. In my drawing, the newer commits are towards the right, while in the original image, the newer commits are towards the top. So the drawings are different but they show the same thing:</div><div></div><div></div><div></div><div></div><div></div><div>download specific commit gitlab</div><div></div><div>Download File: https://t.co/ty70C6wvj1 </div><div></div><div></div><div>A full snapshot of every file. These files are compressed and, importantly, de-duplicated, so that if you make a new commit that mostly re-uses most of the files from an old commit, the new copies literally take no space. But they're still logically copies of the files, so that each commit has a full copy of every file.</div><div></div><div></div><div>Some metadata, or information about this particular commit. The metadata include the name of the person who made the commit, and the date-and-time at which they made it, for instance. Git stuffs into this metadata a list of commit hash IDs, which is usually exactly one entry long. This one-entry list gives the commit number of the parent commit for this particular commit.</div><div></div><div></div><div>So, in our drawing above, commit G lists the number of commit F in its metadata. This means that as long as Git can find G, it can find F. Commit F, being a commit, has snapshot and metadata, and its metadata list the hash ID of commit A as its parent, so Git can move backwards from F to A. A has metadata too, which lists some previous commit (not shown here); this repeats on and on, and the commits we find as we traverse this list backwards, one commit at a time, is the history in the repository. Eventually we get to the very first commit ever, which can't list the hash ID of any previous commit, so its list is empty, and that's where we stop going backwards.</div><div></div><div></div><div>Meanwhile, as long as Git can find commit E, it can use this to find D, which finds C, which finds B, which finds A, which finds whatever comes before A, and so on. So that's the history as seen from ARE-1195.</div><div></div><div></div><div>We noted above that Git needs to find commit G in order to find commit F. Git needs to find commit E in order to find commit D, which it needs in order to find C, and so on. (Either F or B suffices to find A, though.) So how does Git find the random-looking number that designates the most recent ARE-1195 commit?</div><div></div><div></div><div>The answer is that the name ARE-1195 itself holds the commit hash ID. This is what a branch name does for you and Git: it holds a commit hash ID. (In fact, all of Git's references work like this. References or refs include branch names, tag names, remote-tracking names, and many other names. Branch names are a bit special in that .git/config often holds more information on them, but we'll ignore that for this answer.)</div><div></div><div></div><div>We haven't explained Git's index and your working tree here (and won't for space reasons) but when you're removing commits like this, you generally want git reset --hard: you want commits D and E to be totally gone forever, or at least seem that way, so you want to get rid of their effect on Git's index and your working tree, which means using git reset --hard.</div><div></div><div></div><div>That's what git reset --hard will do for you: make it look like those commits are gone. There's one big flaw here though. If you had your Git connect to some other Git software earlier, and had your Git send commits D and E to that other Git, that other Git repository now has those two commits. Git is built to add commits, not to remove them: this git reset --hard trick requires a fair bit of by-hand work, but normal everyday usage of Git will automatically add new commits without a lot of by-hand work. So if you've used git push to send your new commits to someone else, they can easily come back to you, as though the someone-else had made them.1</div><div></div><div></div><div></div><div></div><div></div><div></div><div>If you have never sent these commits anywhere else, using git reset can make them seem to vanish from your repository. Nobody else has them yet and your Git won't hand them over to other Git repositories, because your Git doesn't see them any more. So this is a safe way to get rid of commits, if you have not used git push to send them off.</div><div></div><div></div><div>1Although Git records author and committer names in the commit metadata, Git doesn't look at those while greedily adding new commits to your repository. It just says oooh shiny new commit, must add it and adds it.</div><div></div><div></div><div>Let's suppose further that something in commit D is bad, but that commits D and E have escaped and are out in other Git repositories now. You could use git reset to discard D and E entirely, but they'll come back and re-infect your repository, like some kind of nasty virus. Besides, you like commit E: it's all good! What you'd like to do is back out the effect of commit D.</div><div></div><div></div><div>(1 because we want Git to count back 1 first-and-only-parent link) or similar tells Git: Figure out what changed in D, and undo that change. Make a new commit whose message is revert . The end result is:</div><div></div><div></div><div>Because Git repositories everywhere are greedy for new commits, they will be happy to add this one on, undoing the effect of the one commit. This won't undo the effect of commit E; if you want that you must revert both commits:</div><div></div><div></div><div>Reverting all the commits in a series backs out all the changes in that series. The git revert command is smart enough to do this in reverse order by itself, so that you simply list all the commits to revert. For instance, to revert both D and E you might run:</div><div></div><div></div><div>In short, reset is used to move the tip of a branch to a pre-exiting commit (generally back in time, but not always). revert on the other hand creates a new commit that reverts the changes made by another commit (in essence it's a reversed cherry-pick).</div><div></div><div></div><div>I need to build a Gitlab CI pipeline manually but not using latest of my master branch, but using a specific commitID.I have tried running pipeline manually by using variable as below and passing its value but of no use.</div><div></div><div></div><div>At the time of this writing, GitLab only supports branch/tag pipelines, merge request pipelines and scheduled pipelines. You can't run a GitLab pipeline for a specific commit, since the same commit may belong to multiple branches.</div><div></div><div></div><div>I have been trying to work with the gitlab api to get all my commits back between now and 2 months ago. The problem I have been running into is that I dont get more then 20 commits back. Nowhere i can find how to change it.</div><div></div><div>This is the link I have been working with:</div><div></div><div> _name=master&since=2019-06-01T20:10:10Z&until=2019-09-01T20:10:10Z&all=true</div><div></div><div></div><div>The all parameter is used to retrieve every commit from the repository.</div><div></div><div>all used in combination with path will list all commits to that file across branches, tags and revision ranges, and all used without specifying a ref_name will list all commits to the repository.</div><div></div><div></div><div>Gitlab documentation is not so detailed as compared to what you have explained.</div><div></div><div>I also thought path with all should give me all commits. But strangely for my usecase path gives me the latest commits, path with all as true does gives me 2-3 or 0 commits and same is with path with all as true and ref_name.</div><div></div><div>Thats why had raised this topic, if you can guide me</div><div></div><div></div><div>it means you want to make changes in last 3 commits, you can squash them, delete them, change messages, by the way I use it a lot in my feature branches even when I already pushed some commits then I do forced push to rewrite history on the server, it is ok till I know that only I work on that branch</div><div></div><div></div><div>As long as the commit you are 'undoing' is local and is not part of any remote branch (you have not push-ed it yet), or if this is a one-dev pet project and you are sure nobody is 'consuming' your remote branch (and you can push to it with --force) - git reset is OK.</div><div></div><div></div><div>The thing is - it rewrites history. So if you'll make another commit on top of it but the 'undone' commit is pushed already, the history of your local branch and your remote tracking branch will diverge - and you'd have to push it either to another branch, or with --force, rewriting the remote branch. And if the remote branch is rewritten, anyone who had cloned it won't be able to pull from it any more that easily etc...</div><div></div><div></div><div>Thanks for the suggestion. I used that before, but in the last problems where I had to undo the commits and then push the changes, that was the solution that worked for me. Also, I didn't mind having a commit dedicated to the revert (with the prefix) on the git history. I think it is a possible solution too.</div><div></div><div></div><div>Most of the time, you will want to checkout a branch (and not a specific revision). Branches are very practical because they are pointers to the latest commit in a certain context (it helps to think of branches simply as specific, separate contexts with names).</div><div></div><div></div><div>This means that, actually, branches don't point to a certain commit but really always to the latest commit on the corresponding branch. This also means that, if a new commit is made in that context, the branch pointer is automatically moved to that newest commit. The user does not have to do this manually.</div><div></div><div></div><div>This branch will then be your current working branch, also referred to as "HEAD" in Git. Any new commits you make from this point on (until you switch branches again) will be recorded in this branch's context.</div><div></div><div></div><div>There are very few reasons to checkout a commit (and not a branch). Maybe you want to experiment with a specific, old revision and therefore need to have that revision's files in your working copy folder.</div><div></div><div> 7c6cff6d22</div>
0 new messages