Refs and HEAD
References, or refs, are names that point to Git objects. Branches and tags are examples of refs. HEAD is a special symbolic reference that usually points to the current branch.
This design explains why creating a branch is inexpensive: a branch is essentially a small reference rather than a copy of the entire repository.
Inspect References
git show-ref
git rev-parse HEAD
git symbolic-ref HEAD
git branch --show-current💡 These commands reveal references, the current commit, the symbolic HEAD target, and the active branch.
Key Takeaways
- Branches and tags are references.
- HEAD normally points symbolically to the current branch.
- References make branch creation and movement inexpensive.
Knowledge Check
Why is creating a Git branch usually cheap?