Here's a preview from my zine, ! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
panel 1:
have you ever seen refs/heads/main or HEAD and wondered what they mean?
here’s the deal:
head
= branchHEAD
= current branch
(yes, these are TERRIBLE names)
panel 2: a head in git is a branch
nobody really uses the term “head” for a branch except the official git docs though
panel 3: HEAD is the current branch
for example HEAD could be set to main
it’s stored in .git/HEAD
Unless you don’t have a current branch…
panel 4: HEAD
can be a commit ID instead of a branch
This means you have no current branch. Git calls this a “detached head state” (another terrible name!)
(silly picture of a stick figure whose head has fallen off)
fixing this is easy though:
git checkout BRANCHNAME
panel 5: the current branch matters for these commands
git commit
git rebase
git merge
git cherry-pick
these 4 will work if you have no current branch but will create commits that you have no easy way to refer to
git pull
git push
these don’t work at all if you’re not a branch
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!