4

in one of the repositories I work with some other folks on, we use pull requests as a way to manage our merges and sometimes we get merge conflicts (as normally happens). Here's the rub: other developers have been using the GitHub web interface to do the actual merges (in addition to just creating the PRs).

According to GitHub documentation:

Warning: When you resolve a merge conflict on GitHub Enterprise Server, the entire base branch of your pull request is merged into the head branch. Make sure you really want to commit to this branch. If the head branch is the default branch of your repository, you'll be given the option of creating a new branch to serve as the head branch for your pull request. If the head branch is protected you won't be able to merge your conflict resolution into it, so you'll be prompted to create a new head branch. For more information, see "About protected branches."

Sometimes this is not actually what we want. Here's why.

For example, let's say we're working on two feature branches:

feature/123
feature/456

And feature/123 is in staging but not ready for master.

And we want to merge feature/456 into staging, so we create a PR, and it has merge conflicts.

If someone uses the GitHub web interface to merge that PR, what actually happens is as follows:

  • GitHub will merge staging, which already contains work from feature/123, into feature/456.
  • The user will resolve the conflict.
  • GitHub will merge feature/456 into staging.

Unfortunately, once feature/456 is ready for master, when someone performs that merge, the code changes in feature/123, which are still not yet ready for prime time, will come along with it into master.

I'm 99% certain the idea behind this behavior is that GitHub wants you to resolve the merge conflicts in the head branch instead of the base branch, i.e., feature/456 instead of staging.

Is there a way to have GitHub resolve the conflicts in staging instead?

Darren Embry
  • 155
  • 1
  • 2
  • 1
    P.S. (of course I already know how to use the command line to merge, I want to see if GitHub can do the merge properly, i.e., one way) – Darren Embry Nov 06 '20 at 21:21
  • 1
    I'm not sure about GitHub, but I would stop resolving conflicts in the GitHub UI. Resolve them locally, push your festure branch and then submit the pull request to merge the feature branch into staging. – Greg Burghardt Nov 06 '20 at 23:01
  • 1
    I'm pretty sure what you want to do isn't possible, since the documentation says that it works differently than you want. If you want a different behavior, I think the command line is going to be your option. – bk2204 Nov 06 '20 at 23:09
  • @DarrenEmbry how to do it in command line? I'm in a very similar situation and right now put a PR on hold until I figure this out. Can you please share any resources about how to do it on command line. I think it is not possible in github GUI. – Vignesh Nov 09 '20 at 14:46

0 Answers0