One of the best parts in version control is undo. This is a quick collection of undo commands in git.
Unstage a staged file
If you staged a file in mistake, you can unstage it using
Unmodify a modified file
You made some unsatisfied changes in a file and want to discard it.
You can use
checkout -- command:
Change last commit
If you forget to add some files or mess up your commit messages, use
option to edit your last commit:
This command takes your staging area and uses it for the commit.
amend commit will replaces your last commit.
Redo last commit
If you made a unwanted commit, you can overwrite it using
git reset HEAD^
command like it never happens: