HEAD, HEAD~1 and HEAD@{1} explained
Many commands take a name for a commit. These are the ones you will see most.
The names
| Name | Meaning |
|---|---|
HEAD | The commit you are on now |
HEAD~1 | The commit before it (its parent). HEAD~3 goes back three steps |
HEAD@{1} | Where HEAD was one move ago, from the reflog |
ORIG_HEAD | Where your branch was before a drastic move such as a reset or a merge |
main~2 | Two commits before the tip of main |
feature~1 | One commit before the tip of feature |
The official page gitrevisions describes <ref>@{<n>} as the n-th prior value of that ref. It only works for refs that have a log, which HEAD has in a normal repository.
Back in time versus back in place
HEAD~1 follows the history of commits (what the commit was built on). HEAD@{1} follows what you did (the diary of your moves). After a reset --hard HEAD~1, HEAD~1 is one commit older still, but HEAD@{1} is the commit you just left. That is why the lost-commit page uses HEAD@{1}.
The page on recovering a lost commit ran exactly this and printed the reflog, which shows both numbering styles side by side.
In PowerShell
PowerShell treats @{ as the start of a hashtable. If HEAD@{1} gives an error there, write it in quotes: git reset --hard "HEAD@{1}".
What is the difference between ~ and ^?
HEAD~1 and HEAD^ mean the same for the first parent. They differ for merge commits, which have two parents: HEAD^2 is the second parent.
Can I use a short hash instead?
Yes. Any name that identifies a commit works, for example the first seven characters of its hash shown by git log --oneline.
Sources
- Git documentation: git-reset (git-scm.com/docs/git-reset)
- Git documentation: gitrevisions (git-scm.com/docs/gitrevisions)
- Git documentation: git-config, settings gc.reflogExpire and gc.reflogExpireUnreachable (git-scm.com/docs/git-config)
- Git documentation: git-revert (git-scm.com/docs/git-revert)
Read on 14 November 2026.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.