In this post, I’m going to show how to revert multiple git commits in one go using CLI. Let’s say this is the git history
A -> B -> C -> D -> E -> HEAD
In this example, we want to revert back to commit B. In your Git Bash, run the following commands
git reset --hard B
git reset --mixed E
git commit
This will create a new commit that reverts all your changes back to commit B.
Alternatively, you could just hard reset to commit B and force push. However, you would lose your git history. Also, force push is a dangerous operation and is disabled in our all repositories at work.