Merge conflicts on GitHub, not locally?

Hi - recently my team has encountered an issue where when we open a pull request, GitHub will state that there are merge conflicts between the branches preventing the merge, but if we pull the relevant branches and merge locally with command-line git (with --no-ff option), no conflicts are detected. We have pre-commit linting hooks on our repos so I don’t think the problem is due to whitespace conflicts, etc., and sometimes legitimate conflicts do exists, but most of the time there are no perceivable changes between the conflicted files.

Has anyone else encountered something like this happening? Any help would be appreciated. Thanks!

10 Likes

Hi @pcurc,

I’d recommend checking out our Help Doc on how to resolve merge conflicts specifically on GitHub. You find that here:

https://help.github.com/articles/resolving-a-merge-conflict-on-github/

That article contains information on how to solve merge conflicts on GitHub, and also what to try if those initial steps aren’t working.

I hope this helps!

Hi @pcurc,

Sometimes this can happen because of how GitHub compares branches versus how Git compares branches. GitHub compares branches from the point where they are created whereas Git in the command line generally compares branches from where they are currently.

Therefore, if you have a master and a develop branch and you create a Pull Request at a certain point in time to merge develop into master but then master continues to evolve in a way that resolves a conflict before it would be created, you can get a merge conflict warning in the web interface when you wouldn’t via the command line.

I don’t know if that’s what is happening to you, but if it is, I hope that context helps to explain it.

Thanks!

6 Likes

It sounds very likely that this is the explanation for what’s going on. My question would be, is there anything we can do about this, other than changing our branching strategy?

Briefly, this is how things work:

* Feature branches are made off of master

* Feature branches then merged into develop for testing

* Upon acceptance, feature branches are merged into master for release

* Post-release, master is merged back into develop to get the merge commits from master in there

Thank you for any suggestions!

Other than changing your branching strategy, I’m not sure that there’s any direct workarounds for this. The way that we handled this flow at the last place that I worked is that feature branches would be made off of develop and then merged back into develop for testing which would then be merged into master. It allowed us to have the fewest conflicts with the most test coverage. I understand that this may not work for you, however.

We’re having the same exact problem and changing the branching model isn’t an option when working in a continuous development model where master is always the most reliable source and all other branches are disposable and possibly corruptable by some mistake. 

I’m surprised this problem isn’t more widespread. 

5 Likes

We observed this issue between feature a7dc88d and master ec96c64bf in this PR https://github.com/hail-is/hail/pull/4307. We use a CI/CD system that had tested and verified this PR and then tried to use GitHub’s merge endpoint, but GitHub rejected the merge, claiming it was not mergeable. All of these succeed using the recursive merge strategy:

git checkout master
git merge feature

git checkout feature
git merge master

git rebase master feature

Obviously, this makes us concerned that git isn’t using the same merge strategy as us thus potentially invalidating our testing.

Hi @danking,

It looks like that PR has been fixed since you posted this, so I’m thinking all is well at this time. Is that correct? 

For what it’s worth, we’re having the same issue.  Github’s approach to merging conflicts causes us great difficulty–we are forced to merge all conflicts on the command line because our workflow does not support polluting a feature branch with dev branch content (for us, dev is where separate developers’ code meets for the first time, and often contains code not considered ready for production).  The Github approach forces dev-branch content to be merged into feature branches, which then means those feature branches cannot be merged to production because they now contain dev-branch content.  No option is provided in the Github interface to resolve these merge conflicts, and what’s worse is that after the merge conflict is resolved locally, Github does not resolve the merge conflict when those changes are pushed to remote (i.e. Github itself).

The desired solution would be to provide options, within Github, specifying how merge conflicts are handled, instead of forcing us to merge the pull-request target (“base”) branch into the source (“compare”) branch.

2 Likes

I just had this same problem.

I think it might have been caused by using the GitHub PR ‘This branch is out of date’ UPDATE/MERGE button.

Solved the problem by running git command line merge i.e. 

git merge master

In future I will use command line instead of GitHub PR merge to avoid this problem.

2 Likes

I had the same problem and learned from experience that I should merge from master to my dev branch on my machine so that I can resolve the conflicts on my machine rather than letting GitHub do it (GitHub conflicts resolver looks completely unusable to me).

I had a similar problem in the following case:

  • Branch A is based off Master and has commits X, Y, Z

  • Branch B is based off Branch A and has commits X, Y, Z, P, Q; so that only P and Q show as part of this PR

  • Squash-merge branch A into Master

  • Rebase Branch B from new Master, dropping X, Y and Z, leaving P and Q

  • Force-push the rebased Branch B, now just P and Q, and change its base to Master

  • Try to squash-merge branch B into Master, run into this problem

What happened was, somehow Github got stuck in an in-between state, reporting merge conflicts on the remote as if I was trying to merge a squash-merged Branch A into Branch A despite having completed the change of base branch. These conflicts didn’t actually exist so couldn’t be resolved, locally (merging Master into Branch B was a no-op) or through GitHub’s interface.

What fixed it for me was changing the base branch again, waiting a bit, and changing the base branch back again. I think maybe something got snarled up and stuck because I changed the base branch too quickly after force-pushing the rebase.

Actually,  I’ve also this problem Please if anyone found any solution the Merge conflicts then Please let me know also

Thanks

Ran into this issue as well…

I have the following branches main, A, B.

  • A is based off main
  • B is based off A

I merged A into main with rebase and merge and after that GitHub says B cannot merge into main because there was merge conflict… So I tried to pull the latest main into my local dev machine and tried rebase B onto main locally and it worked without any conflicts… WAT?!

There are no other branches or merges involved at all.

@that-pat Is there anything else GitHub can do to help with this situation? I have been running into this constantly. Example in my reply above.

Happens in our project too. In one of our repos we always have this when merging staging branch into develop. It also happens in other repo but very rarely, and in seemingly random circumstances.

@nadiajoyce Please check other replies since you seem to became inactive in this thread. This issue is persistent and repeatable in one of our repos.

Happened to us today:

  • Feature branch taking out of develop branch
  • Regular update of feature branch from develop using merge
  • At some point in time, github decided that this was no longer acceptable and tagged the PR with merge conflicts
  • Updated the feature branch again from develop → still conflict
  • Rebase feature branch from develop → still conflict
  • Checkout develop branch and merge feature branch → no conflict
  • In a word → bamboozle

Guess I’ll have to do the merge manually instead of going through Github, but that raises some eyes brows onto how github handles merges…

I just ran into this today too.

git pull and git fetch say I’m up to date.

Latest commits are showing up correctly in github.

However, there’s also a warning about merge conflicts on github.

They didn’t show up on my local machine until I did git pull origin master.

Note that these are not conflicts within the current branch, which is what the UI seems to be suggesting.

Hope that helps someone.

This is also an issue for our team as well.

I have the same workflow as most of the others above.

  1. We create features of develop
  2. Merge those features back into develop throughout the sprint
  3. Cut release branch off develop before release
  4. Once release is complete we then create a PR to merge the release branch into master

The idea is that the changes from develop/release are already approved and contain no conflicts. We just want the changes from release to merge directly in master and that works fine on the cmd but I have to spend hours sometimes, when using the PR web UI, because it thinks there are conflicts. It doesn’t seem to even be able to handle simple blank line deletions or whitespace changes. It’s a huge pain.