What exactly is a 'ref' in Git, and where are refs stored inside the .git directory?
Last updated
A ref is a human-readable name pointing to a commit SHA (or a symbolic ref pointing to another ref, like HEAD →
refs/heads/main). Branches, tags, andHEADare all refs.Stored under
.git/refs/heads/(branches),.git/refs/tags/, and.git/refs/remotes/. Special refs likeHEADsit at the top of.git/.Refs may be consolidated into
.git/packed-refs, so inspect them withgit show-reforgit update-refinstead of editing files.
- https://git-scm.com/book/ms/v2/Git-Internals-Git-References
- https://blog.devgenius.io/what-are-git-refs-the-invisible-threads-of-version-control-3200d8f594c8
- https://learnsome.tech/glossary/git-ref
- https://git-scm.com/docs/git-pack-refs/2.0.5
- https://dev.to/shrsv/unpacking-gits-branching-a-look-at-the-internals-b4a
- https://coderssecret.com/blog/git-internals-how-git-works-under-hood
- https://gitperf.com/chapter-17.html
- https://www.atlassian.com/git/tutorials/refs-and-the-reflog