Oct 7, 2026

I have recently improved my mental model of Git. Consider these two git commands:

$ git fetch origin master
$ git switch -c my-feature origin/master

Do you understand why is it origin master in one command, and origin/master in the other? I didn’t, until a few weeks ago!

My understanding was that git is a content-addressable database. Git stores commits, a commit is identified by the hash of its content, and the content of a commit is, primarily:

  • a memory-less snapshot of a state of the codebase at a given point in time,
  • a list of (hashes of) parent commits.

That was enough git for me to understand git log output and get me out of any botched rebase without having to re-clone the repo (For roughly half of my career, I was re-cloning the repo. No shame in that! Learning git is useful, but it’s not the highest priority thing to learn when you start).