Your daily Git workflow

Practice with a small repository

Build a short history that includes new, modified, staged, ignored, and committed files.

8 minute lesson

~~~

Create a disposable notes-project folder with a README and two text files.

Initialize Git. Before each command, predict the working-tree, index, and HEAD state. Then verify with git status and the appropriate diff.

Build this history:

  1. Add the README in the first commit.
  2. Add one notes file in the second commit.
  3. Improve both files, but stage and commit only one.
  4. Add notes.local to .gitignore and commit the rule.
  5. Finish the remaining change in a final commit.

After every commit, run:

git status
git log --oneline --decorate

At least once, stage a file and edit it again. Use git diff and git diff --staged to explain which version the next commit will contain.

Do not rush. The goal is not to memorize commands. The goal is to predict which state each command reads and changes.

When you finish, draw the commits as boxes connected by parent arrows. Mark the commit your current branch points to and where HEAD points.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →