Staging a Change

Committing is two steps, not one. Git does not snapshot everything you have edited — it snapshots what you have explicitly staged.

That gives you a middle ground: the working directory holds everything you have changed, the staging area holds the subset you have chosen for the next commit.

It seems like a nuisance until the first time you want to commit two of your five changes and leave the rest for later.

Exercises

  1. Exercise 1. There is an edit to "readme" sitting unstaged. Stage it, then commit it — watch it move Working dir → Staged → into the commit.
  2. Exercise 2. Now the point of staging: two files are edited, but only "readme" is ready. Commit that one and leave "styles" unstaged for later.