Track
Undoing Things
6 Lessons, then a Checkpoint of 3 Challenges.
Builds on Branching & Merging.
Lessons
Follow them in order, or play any Lesson once the Track is unlocked.
- Discarding and unstaging
A file in a repository can have three versions at once:
3 Challenges.
New commands:
git restoregit restore --staged
- Fixing the last commit
You've just committed, and then you spot a typo in the message. Or a file you forgot to add. You don't need a second commit to fix it: git commit --amend…
3 Challenges.
New commands:
git commit --amend
- Moving a branch back
git reset <commit> moves the branch you're on to another commit. Usually that's back in time: git reset HEAD~1 moves it back one commit, and git reset HEAD~2…
3 Challenges.
New commands:
git resetgit reset --softgit reset --mixedgit reset --hard
- Undoing in public
Amend and reset rewrite history: they take commits off your branch. That's fine for commits only you have. But once you've shared a commit, by pushing it or…
3 Challenges.
New commands:
git revertgit revert --no-editgit revert --abort
- Rescuing lost work
Committed work is hard to lose. A reset, an amend or a deleted branch takes commits off a branch, but the commits themselves stay in the repository. What's…
3 Challenges.
New commands:
git reflog
- In the wild
Until 2019, git had no switch and no restore. One command did both jobs: git checkout. It's still everywhere, in older tutorials, in answers online, in…
3 Challenges.
New commands:
git checkoutgit checkout -bgit checkout --
Checkpoint
The Track ends with a Checkpoint of 3 Challenges that use only this Track's commands and those of the Tracks it builds on. Passing the Checkpoint completes the Track, even before you have played every Lesson.