aguisa
aguisa

Reputation: 351

How to revert a merge with git

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>

Upvotes: 1

Views: 224

Answers (1)

The Pax Bisonica
The Pax Bisonica

Reputation: 2164

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.

Upvotes: 2

Related Questions