Stage 2 · Lesson 8 of 8
stash, log and undoing mistakes
is a skill of its own: everyone makes mistakes, and the trick is picking the right undo. git stash puts uncommitted changes on a shelf so you can switch , and git stash pop brings them back. git restore file throws away your edits to a file, and git restore --staged file takes it out of the .
git commit --amend fixes the last commit's message or adds a forgotten file, before you push. git revert makes a new commit that undoes an old one, and it is the safe choice on history others share. git reset moves your branch back.
With --hard, it also throws work away, so use it only on commits you have not pushed. git log and git reflog (a record of where your branch has been) help you find what you think you lost.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
MIT lectures on dev tools; the shell, shell tools and version control lectures are enough
- GitHub repoFreeGitHub Skills: Introduction to GitHub
GitHub · Beginner
Free one-hour exercise: branch, commit, open and merge a pull request