Git refs¶
Resources¶
Refs live under .git/refs
. There are two kinds of refs: heads
and tags
.
Using refs via plumbing commands¶
From a-plumbers-guide-to-git.
Updating/Creating a ref¶
git update-ref refs/heads/master 092eb0b62c3eb4466ece5ff6cc9c98b1cf6da0a8
cat .git/refs/heads/master
# 092eb0b62c3eb4466ece5ff6cc9c98b1cf6da0a8
Refs under the heads
directory are called branches.
Creating another branch¶
This creates a ref at .git/refs/heads/dev
. That’s all a branch is – a pointer
file.
HEAD ref¶
HEAD
is a special ref that lives in .git/HEAD
.
Changing HEAD:
Using Tags via refs¶
Similar to branches, a tag is just a lightweight pointer.
Overall view¶
Here's how refs fit in the picture with commits, trees, and blobs.