-1

Few weeks ago in one of my projects I merged а branch into master. Later I realize that the branch I merged into master has changes that I don't want to be in master. Is it possible to revert the changes in master made by this branch?

MZON
  • 305
  • 1
  • 3
  • 10

1 Answers1

0

Yes, it’s possible. You just need to execute git revert <commit> on master branch.

Assume your commit history as below for now:

  A---B---C mybranch
 /         \
D---E---F---G---H master

If you want to revert the changes from commit B by mybranch, you can use the command:

# On master branch
git revert <commit id for B>

Then the commit history will be:

  A---B---C mybranch
 /         \
D---E---F---G---H---B' master

Note: if there has conflict during the revert, you can modify and save the conflict file(s), and then use git add . and git revert --continue to finish the revert.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74