Answers for "roll back to last commit"

33

roll back last commit in git

git reset --soft HEAD~1
Posted by: Guest on March-30-2020
2

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
Posted by: Guest on September-22-2020
0

git revert last commit

git revert HEAD
Posted by: Guest on April-12-2021
0

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
Posted by: Guest on January-12-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language