Git revert multiple commits

2023-04-10

Today I learned how to revert multiple commits in git at once with only one commit.

The following commands revert the last three commits:

git revert -n HEAD~3..
git commit -m "Commit message"

The two dots .. are important. They create a range from HEAD to HEAD~3. The -n flag makes it possible to put the whole process into a single commit.

Source: This nice stackoverflow answer.