Git Reference / Revision syntax
22Revision syntax
Ways to name a commit anywhere Git expects one.
| Syntax | Meaning |
|---|---|
HEAD | The current commit |
HEAD~3 | Three commits back along first parents |
HEAD^2 | The second parent of a merge commit |
main@{upstream} / @{u} | The branch’s upstream (e.g. origin/main) |
main@{2.days.ago} | Where main pointed two days ago (reflog) |
A..B | Commits in B not in A (“what’s new on B”) |
A...B | Commits in either but not both; in diff, changes since the merge-base |
:/fix login | Most recent commit whose message matches |
v1.0:src/app.js | A file’s contents at a revision |