How to revert a merge with git

212 views Asked by At

I've been working in a branch that has many commits. Once pushed and merged to 'master', what's the best option to revert changes all merged commits from the branch i was working in 'master'?

What about this?

git revert -m 1 <merge-commit>
1

There are 1 answers

0
The Pax Bisonica On

The best way to do this is by first merging your branch in using the --no-ff option.

git merge --no-ff your-dev-branch

What this does is create whats called a merge commit for you. If you want to revert the merge, you only have to revert that merge commit. If you don't specify the --no-ff flag, then there may be a chance that it doesn't create the merge commit.