# KEEP CHANGES
git reset --soft HEAD~1
# REMOVE CHANGES
git reset --hard HEAD~1
# Uncommit the changes
git reset --soft HEAD~1
# Completely delete the changes
git reset --hard HEAD~1
#this will preserve changes done to your files
git reset --soft HEAD~1
#this will get rid of the commit and the changes done to the files
$ git reset --hard HEAD~1
# Reset the index and working tree to the desired tree
# Ensure you have no uncommitted changes that you want to keep
git reset --hard 56e05fced
# Move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Reverting to the state of the project at f414f31"
# Undo last commit.
# --soft flag makes sure that the changes in undone revisions are preserved.
# You'll find the changes as uncommitted local modifications in your working copy.
git reset --soft HEAD~1
# If you don't want to keep these changes, simply use the --hard flag.
# This will completely remove the changes.
git reset --hard HEAD~1
$ git reset --soft HEAD~1
$ git reset --hard HEAD~1
git revert <the_commit_hash>
git revert <commit hash>
git revert
$ git reset HEAD^
$ git revert HEAD
If your commits are only LOCAL,
you can git reset --hard origin/<branch_name>
to move back to where the origin is.
git revert <commit to revert>
git reflog //to get commitID
git reset #commitID
git reset <commitId>
# Exemple
git reset 5310517
$ git log --oneline
b764644 File with three lines
7c709f0 File with two lines
9ef9173 File with one line
$ git log --oneline
9ef9173 File with one line
git reset --hard <sha1 of desired commit>