xxxxxxxxxx
git reset --soft HEAD^ # Use --soft if you want to keep your changes
git reset --hard HEAD^ # Use --hard if you don't care about keeping the changes you made
xxxxxxxxxx
# Resets index to former commit; replace '56e05fced' with your commit code
git reset 56e05fced
# Moves pointer back to previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
# Updates working copy to reflect the new commit
git reset --hard
# Push your changes to respective branch
git push -f
xxxxxxxxxx
git log
commit 101: bad commit # Latest commit. This would be called 'HEAD'.
commit 100: good commit # Second to last commit. This is the one we want.
To restore everything back to the way it was prior to the last commit, we need to reset to the commit before HEAD:
git reset --soft HEAD^ # Use --soft if you want to keep your changes
git reset --hard HEAD^ # Use --hard if you don't care about keeping the changes you made
xxxxxxxxxx
//git use a new commit to replace an old commit,commit moves foward not backward
git revert <commit hash>
//Git goes back one spot on the log,undone this commit and go backward one commit:
git reset HEAD~1
//Git looks for and rolls back to a certain file:
git checkout commit-hash-here -- file/location/and/name
xxxxxxxxxx
git reset --hard branch_name #Reverts all modified files to last commit on branch
xxxxxxxxxx
# Revert is the command to rollback the commits.
git revert 2h3h23233
# push after change
git push