Git Internals Refs


Example

A ref is essentially a pointer. It's a name that points to an object. For example,

"master" --> 1a410e...

They are stored in `.git/refs/heads/ in plain text files.

$ cat .git/refs/heads/mainline
4bb6f98a223abc9345a0cef9200562333

This is commonly what are called branches. However, you'll note that in git there is no such thing as a branch - only a ref.

Now, it's possible to navigate git purely by jumping around to different objects directly by their hashes. But this would be terribly inconvenient. A ref gives you a convenient name to refer to objects by. It's much easier to ask git to go to a specific place by name rather than by hash.