Git: Commit Referencing Syntax
Wiki Index
- AWS
- Concurrency
- Databases
- Distributed Systems
- Git
- Extract File from a Git Stash
- Git: Cherry-Pick a Range of Commits
- Git: Commit Referencing Syntax
- Git: Connect to a Remote via a SOCKS Proxy
- Git: Show File at Commit/Tag/Ref
- Hardware
- Languages
- Low Level
- Math
- ML
- Networking
- Operating Systems
- Performance
- Projects / Hands-On
- Puzzles
- Resources
- Software Engineering
- Tools
- Web
- Writing / Documentation
There are a couple of different ways to refer to a commit:
- Full SHA:
7fa145658ded8b44c3df134c3161c21df9b0ad4b
- Abbreviated SHA:
7fa145
- Branch name:
branch-name
- Reflog
- Previous
HEAD
:HEAD@{1}
- Five
HEAD
s ago:HEAD@{5}
HEAD
yesterday:HEAD@{yesterday}
- Previous
- Parent:
7fa145^
- Parent of parent:
7fa145^^
or7fa145~2
- 5 parents “above” current commit:
7fa145^^^^^
or7fa145~5
Similarly for a range of commits:
- Commits reachable from
branch-a
but not frombranch-b
:branch-b..branch-a
or^branch-b branch-a
- Commits reachable from
branch-a
andbranch-b
, but not frombranch-c
:branch-a branch-b ^branch-c
- Commits reachable from
branch-a
orbranch-b
(but not both):branch-b...branch-a
(use--left-right
to disambiguate)