Git: Version Control of the World

Introduction Agents write all the code, but I still make the Git commits. That’s my last remaining contribution. (T_T) Treat this as a Git quick reference, though it could also serve as a tutorial. The official cheat sheet is much better than mine. Working tree, index, and HEAD flowchart TD W["Working tree: files on disk"] -->|"git add"| I["Index: staged snapshot"] I -->|"git commit"| C["Commits"] I -->|"git restore"| W subgraph LOCAL["Local repository"] H["HEAD"] -.->|"normally refers to"| B["Current branch"] B -.->|"points to"| C end Working tree: the files you edit on disk. Index (staging area): the snapshot prepared for the next commit. Local repository: stored objects, including commits, and references such as branches. HEAD: normally refers to the current branch, which points to a commit. With a detached HEAD, it points directly to a commit. Lazygit I recommend Lazygit, a terminal user interface (TUI) for convenient Git operations. ...

June 1, 2025 · 8 min · 1645 words · Square Zhong