Skip to content
techsnow

Git Basics

Undoing Changes

SituationCommand
Discard changes to a filegit restore index.html
Unstage a filegit restore --staged index.html
Fix the last commit messagegit 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 aftergit reset --hard 7b1e0d4