Git Basics
Undoing Changes
| Situation | Command |
|---|---|
| Discard changes to a file | git restore index.html |
| Unstage a file | git restore --staged index.html |
| Fix the last commit message | git commit --amend -m "Better message" |
| Undo a commit safely (makes a new commit) | git revert a3f9c21 |
| Go back to an old commit and discard everything after | git reset --hard 7b1e0d4 |