1

I have a feature branch called feature. I merged it to the master but then realize it's not ready to release yet, so I have to revert it to avoid blocking work of other people.

Note that I don't have permission to revert directly on master. To revert, I have to create a new branch feature_revert from master, revert the merge and merge this new branch to master again.

Now after a while and my changes are ready to merge again, what's the correct way to re-merge to master?

  1. Simply merge the feature branch to master again. Since I didn't revert directly on master, will Git be able to merge this or it will still recornize this branch as already merged?
  2. Revert the revert on feature_revert and merge it back to master
  3. Create a different branch feature_remerge, merge the change from feature to this new branch and merge this new branch to master

Sorry if I make things a bit complicated. Just want to know what's the best practice in this situation.

user1417127
  • 1,525
  • 1
  • 21
  • 29
  • Does this answer your question? [How to fix a Git master branch after accidently merging the wrong branch?](https://stackoverflow.com/questions/54307602/how-to-fix-a-git-master-branch-after-accidently-merging-the-wrong-branch) – j6t Jun 27 '21 at 06:40
  • git doesn't care, or even know, if something happened "directly on master" or on a branch that was merged in: master's history is every commit reachable by following parent pointers, including both sides of any merge commits. – IMSoP Jun 27 '21 at 10:32

1 Answers1

1

Simply merge the feature branch to master again.

That should not work indeed, since it was already merged as part of a PR.

Creating a new separate branch (option 3: feature_remerge) is the easiest way to proceed, in order for the right merge content to be merged to master.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250