roll back last commit in git
git reset --soft HEAD~1
git revert all commits to pervious commit
git revert --no-commit <commithash>..HEAD #revert changes in range of commits from head to back to that commit hash
git return to last commit
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us