Re: several quick questions
flat view
From: Carl Worth <hidden>
Date: 2016-06-15 22:42:19
On Tue, 14 Feb 2006 09:05:16 -0800 (PST), Linus Torvalds wrote:
Both of these can be solved with "git reset".
...
- "git branch". This creates a new branch of development at an arbitrary point (that defaults to "current state"). - "git checkout". This switches to another branch. - "git reset". This will reset the current branch state to something else.
Thanks for the summary. I don't know if it's the original poster's question or not, but an operation I don't see in the above is "put the working files into the state of a given revision". I recently needed this for some historical investigation, (specifically examining all release tags to ensure that the results after a git import match the results of what we get from the former CVS repository). In this kind of historical exploration, the notion of a "current branch" isn't interesting, since I won't be doing any commits. So the handling of the current branch in the above commands ends up getting in my way [*]. Is there a more fundamental operation to "put the working files into the state of the index"? If that exists, then that combined with git-read-tree would give me what I wanted I think. -Carl [*] I did succeed in performing the operation, but only in rather awkward ways. Here are a couple of versions of "put the working files into the state of <revision>", both requiring the use of an otherwise unnecessary branch, (bogus-branch): 1) Ensure bogus-branch doesn't exist, then create it at <revision>: # Can't be on bogus-branch when we delete it git checkout master # Use -D to force the removal, ignore errors for branch-does-not-exist git branch -D bogus-branch >& /dev/null || true # Create the branch where we want it git checkout -b bogus-branch <revision> 2) Ensure that bogus-branch exists somewhere (don't care where), then move it: # Create the branch (if it doesn't exist) git checkout -b bogus-branch >& /dev/null # Switch to it (which doesn't happen above if it already existed) git checkout bogus-branch # Move the branch to the revision of interest git reset --hard <revision>
Attachments
- (unnamed) [application/pgp-signature] 189 bytes