Episode 8 of 14
Undoing Changes
Learn about Undoing Changes
Discard local changes: If you modified a file but want to revert it back to its last committed state, use the checkout command.
Execute discard command: Run git checkout -- followed by the filename to throw away any uncommitted changes.
Unstage a file: If you staged a file by mistake using git add, you can pull it back out of the staging area.
Execute unstage command: Run git reset HEAD followed by the filename to unstage it without losing your modifications.
Modify the last commit message: If you made a typo in your last commit message, run git commit --amend -m "New message".
Revert an entire commit: Use the git revert command followed by a commit hash to create a new commit that undoes the changes of the specified commit.