Host: OpenUTD
Speaker: C. Michael Murphey
Contact: michael@murphey.org
ref is short for reference
A ref is kind of like an alias for a commit
Just like anything else in Linux, a ref is actually a file
You can find each ref in the .git
directory
a branch is actually just a ref
a tag is actually just a ref
Many of you have probably interacted with HEAD
HEAD is actually just a (special) ref!
It's basically just a fancy alias for a commit
Project maintainers often tag the last commit of a version
git tag v1.0.1
It's basically just a fancy alias for the most recent commit
git reset HEAD
will reset back to the most recent commit
You can look at what a ref is pointing to with git rev-parse insert-ref-here
You can look at what's in that commit with git show insert-ref-here
Since refs are just plain text files, you can read them with a text editor
You may see
You can manually modify and create refs by editing files in .git/
Don't do this in any repos you actually care about
This contains the metadata of the commit and points to a tree object
Trees can have other trees and/or blobs as children. They represent directories.
These contain the (compressed) contents of a file being tracked
The reflog keeps track of almost everything you do with refs
You can see the history with git reflog
You can go back in time by checking out objects and refs from the reflog
Git's garbage collector helps conserve disk space
The garbage collector which will remove unused objects, prune the reflog and move refs into the file .git/packed-refs
Many of git's commands will automatically invoke the garbage collector
The garbage collector can be run manually with git gc
Warning: now there's actually no going back
refs can point to other refs or commit objects
commit objects can point to other commit objects and trees
tree objects can point to other trees or blobs
blob objects contain the contents of the files in the git repository