Tutorials · Chapter D (4/4) · ~10 min
Git basics
Try it → see it → read → next
Save meaningful snapshots of a project so you can inspect, compare, and recover your work.
Try yourself
Playground
Git time machine
Walk commit → branch → break → recover → PR — one step at a time.
1 / 5
- → 1. Make a commit
- ○ 2. Create a branch
- ○ 3. Break a file (oops)
- ○ 4. Recover with checkout / reset
- ○ 5. Open a PR
Stage a focused change and commit with a clear why.
Recap
What you just did
GitTimeMachine walked commit → branch → break → recover → PR. Local history is how you undo mistakes without rewriting shared remotes carelessly.
Teach
How it works
The everyday loop is:
git status
git diff
git add train.py README.md
git commit -m "Add held-out model evaluation"
git log --oneline
- Working tree contains your current files
- Staging area selects what the next commit includes
- Commit stores a snapshot plus message
- History lets you compare decisions over time
Mental model: Git is a project time machine with named, intentional checkpoints.
Use it
When you'd use this
- Saving a working experiment before trying a risky change
- Reviewing exactly what code changed
- Collaborating without emailing folders named
final-v7
Watch out
Watch out
Git is not automatic backup until history exists somewhere else. Never commit API keys, credentials, private datasets, or a virtual environment. Review git diff and git status before each commit.
Try next
Try this next
Change one harmless line, inspect the diff, then restore it manually. Confirm git status returns to clean.