Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 13

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!

12 Replies
Highlighted
Moderator
Message 2 of 13

Re: Merge conflicts on GitHub, not locally?

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!

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Community Manager
Message 3 of 13

Re: Merge conflicts on GitHub, not locally?

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!

Highlighted
Copilot Lvl 2
Message 4 of 13

Re: Merge conflicts on GitHub, not locally?

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!

Highlighted
Community Manager
Message 5 of 13

Re: Merge conflicts on GitHub, not locally?

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.

Highlighted
Ground Controller Lvl 1
Message 6 of 13

Re: Merge conflicts on GitHub, not locally?

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. 

Highlighted
Ground Controller Lvl 1
Message 7 of 13

Re: Merge conflicts on GitHub, not locally?

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.

Highlighted
Ground Controller Lvl 1
Message 8 of 13

Re: Merge conflicts on GitHub, not locally?

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.

Highlighted
Moderator
Message 9 of 13

Re: Merge conflicts on GitHub, not locally?

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? 

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Ground Controller Lvl 1
Message 10 of 13

Re: Merge conflicts on GitHub, not locally?

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.