Here's a preview from my zine, Oh Shit, Git! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
get the zine!
read the transcript!
A branch in git is a pointer to a commit SHA
master → 2e9fab awesome-feature → 3bafea fix-typo → 9a9a9a
Here’s some proof! In your favourite git repo, run this command:
$ cat .git/refs/heads/master
“master” is just a text file with the commit SHA master points at!
Understanding what a branch is will make it WAY EASIER to fix your branches when they’re broken: you just need to figure out how to get your branch to point at the right commit again!
3 main ways to change the commit a branch points to:
git commitwill point the branch at the new commitgit pullwill point the branch at the same commit as the remote branchgit reset COMM T_SHAwill point the branch atCOMM T_SHA