git revert commited changes code example
Example 1: roll back last commit in git
git reset --soft HEAD~1
Example 2: undo last commit
#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
Example 3: how to revert a git revert
git revert <commitHashOfTheRevert> # locate the hash the revert was done
#this will invert the changes made in that commit
#and preserve the git history
Example 4: revert to commit git
# This will detach your HEAD, that is, leave you with no branch checked out:
git checkout 0d1d7fc32