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:
- Add the README in the first commit.
- Add one notes file in the second commit.
- Improve both files, but stage and commit only one.
- Add
notes.localto.gitignoreand commit the rule. - 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