Git commands used to feel like spells to me. Say the right words and it works. Say the wrong ones and something breaks, and you have no idea why.
What finally fixed that wasn't another cheat sheet. It was seeing what each command does to the picture . So I built a page for myself that draws it, and then I made it public:
š git-drawn-out.vercel.app
It's free, has no sign-up, and works on a phone. The source is on GitHub under the MIT license.
The whole idea: four things
Almost everything in Git is a combination of four ideas:
Commit. A snapshot of every tracked file, plus the ID of its parent. Arrows point backwards: a child knows its parent, never the other way round.
Branch. A sticky note holding one commit ID. Committing moves the note forward. Creating a branch copies nothing.
HEAD. "You are here." It normally points at a branch, and that branch is the one that moves when you commit.
origin/main. Your repo's memory of where the server's main was the last time you talked to it.ā¦