What do these symbols refer to and what do they mean?
(I can\'t find any explanation in official documentation)
From git reset
"pull" or "merge" always leaves the original tip of the current branch in
ORIG_HEAD
.
git reset --hard ORIG_HEAD
Resetting hard to it brings your index file and the working tree back to that state, and resets the tip of the branch to that commit.
git reset --merge ORIG_HEAD
After inspecting the result of the merge, you may find that the change in the other branch is unsatisfactory. Running "
git reset --hard ORIG_HEAD
" will let you go back to where you were, but it will discard your local changes, which you do not want. "git reset --merge
" keeps your local changes.
Before any patches are applied, ORIG_HEAD is set to the tip of the current branch.
This is useful if you have problems with multiple commits, like running 'git am
' on the wrong branch or an error in the commits that is more easily fixed by changing the mailbox (e.g. +errors in the "From:" lines).In addition, merge always sets '
.git/ORIG_HEAD
' to the original state of HEAD so a problematic merge can be removed by using 'git reset ORIG_HEAD
'.
Note: from here
HEAD is a moving pointer. Sometimes it means the current branch, sometimes it doesn't.
So HEAD is NOT a synonym for "current branch" everywhere already.
HEAD means "current" everywhere in git, but it does not necessarily mean "current branch" (i.e. detached HEAD).
But it almost always means the "current commit".
It is the commit "git commit
" builds on top of, and "git diff --cached
" and "git status
" compare against.
It means the current branch only in very limited contexts (exactly when we want a branch name to operate on --- resetting and growing the branch tip via commit/rebase/etc.).Reflog is a vehicle to go back in time and time machines have interesting interaction with the notion of "current".
HEAD@{5.minutes.ago}
could mean "dereference HEAD symref to find out what branch we are on RIGHT NOW, and then find out where the tip of that branch was 5 minutes ago".
Alternatively it could mean "what is the commit I would have referred to as HEAD 5 minutes ago, e.g. if I did "git show HEAD" back then".
git1.8.4 (July 2013) introduces introduced a new notation!
(actually, it will be for 1.8.5 or 1.9, Q4 2013: reintroduced with commit 9ba89f4 )
Instead of typing four capital letters "
HEAD
", you can say "@
" now,
e.g. "git log @
".
See commit cdfd948
Typing '
HEAD
' is tedious, especially when we can use '@
' instead.The reason for choosing '
@
' is that it follows naturally from theref@op
syntax (e.g.HEAD@{u}
), except we have no ref, and no operation, and when we don't have those, it makes sens to assume 'HEAD
'.So now we can use '
git show @~1
', and all that goody goodness.Until now '
@
' was a valid name, but it conflicts with this idea, so let's make it invalid. Probably very few people, if any, used this name.
A blog post during the 1.8.4-rc3 period (14th, August 2013) announced that this feature was reverted and delayed (Thank you Cupcake for the heads-up).
Again, it is introduced again with commit 9ba89f4 (Sept. 2013).
See commit 2c2b664:
@
shortcut for HEAD
"This reverts commit cdfd948, as it does not just apply to "
@
" (and forms with modifiers like@{u}
applied to it), but also affects e.g. "refs/heads/@/foo
", which it shouldn't.The basic idea of giving a short-hand might be good, and the topic can be retried later, but let's revert to avoid affecting existing use cases for now for the upcoming release.