This site runs best with JavaScript enabled.

GIT Revert

Kevin Beck

December 21, 2020


To jump back to a previous commit hash.

"The --no-commit flag lets git revert all the commits at once- otherwise you'll be prompted for a message for each commit in the range, littering your history with unnecessary new commits." - https://stackoverflow.com/a/21718540

"If you really do want to have individual commits (instead of reverting everything with one big commit), then you can pass --no-edit instead of --no-commit, so that you don't have to edit a commit message for each reversion." - https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit#comment37873063_21718540

git revert --no-commit 1234567..HEAD
git commit

This way will not destroy any history so can can used for public commits.

Source