1

We have a workflow where each feature branch must have only one commit.
Then we have a develop branch, where we merge all feature branches, and once those changes are approved, we create PR to a release branch, and merge the same feature branch to the release branch.

But there are times when there are conflicts and resolving conflicts need merging develop branch into the feature branch.
This brings a lot of unwanted commits into the feature branch, which we don't want as the rule for feature branch is that there should be only one commit pertaining to the feature only.
Also merging this into release branch brings a lot of unwanted commits which is not accepted by the PR incharge.

So my question is, that is there a way to undo all base branch commits from feature branch after conflict is resolved?
Or is there a way to resolve merge conflits without merging base branch into feature branch?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
gitstudent
  • 11
  • 1
  • @matt yes we create PR to develop branch and merge it. If there are conflicts then github automatically creates a merge commit also. Not sure of squash merge, never used it. – gitstudent Mar 11 '21 at 04:04
  • @matt you are right, there are three types of PR merges like you have mentioned. We do the first one. These earlier questions also confirm that PR merges in case of conflicts on github creates base branch merges. [link]https://stackoverflow.com/questions/48301279/why-does-github-merge-base-into-feature-branch-after-conflict [link] https://github.community/t/why-does-github-merge-base-into-feature-branch-after-conflict/1027 – gitstudent Mar 11 '21 at 04:39

1 Answers1

0

But there are times when there are conflicts and resolving conflicts need merging develop branch into the feature branch.

You never merge integration branches (like develop) into feature branches, precisely because it "brings a lot of unwanted commits into the feature branch".

What you do is:

  • rebase the feature branch on top of develop (but that will replay feature on top of all develop commits, which might not be what you want)
  • force push the feature branch: that will update any PR in progress.

Or

  • add new commits replacating (cherry-picking) what feature lack
  • push again
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250