Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, How Git Works! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript". get the zine!
read the transcript!

git has a 2-stage commit process

  1. tell git what you want to stage (git add, git rm, git mv, etc.)
  2. make the commit with git commit

Diagram showing two boxes, labelled “untracked files” and “unstaged changes”. They converge into a box labelled “stage” via git add. They then flow into a box labelled “committed”, which has a heart and smiley face beside it, via git commit.

git uses 3 terms interchangeably for the staging area

  1. staged (like --staged)
  2. cache (like --cached)
  3. index (like --keep-index)

it’s total chaos but they’re all the same thing

tiny illustration of a sad stick figure with curly hair: why

tip: you can use git add -p to commit only certain parts of a file

person: I only want to commit my actual changes, not all the random debugging code I put in

gotcha: git diff only shows unstaged changes

You can use:

  • git diff HEAD to see ALL changes you haven’t committed yet
  • git diff --cached to see staged changes

gotcha: git commit -a doesn’t automatically add new files

person: I CONSTANTLY forget to add new files and then get confused about why they didn’t get committed