14

I have a pull request for which GitHub tells me "This branch has conflicts that must be resolved." I tried:

~/src/networkx: git rebase origin/master
Current branch topo is up to date.
~/src/networkx: git merge origin/master
Already up-to-date.
Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Neil G
  • 32,138
  • 39
  • 156
  • 257
  • IF there are a lot of conflicts in a file it might be worth looking at using git checkout with the --ours or --theirs flag - sometimes easier than solving the conflicts manually – gpullen Aug 06 '15 at 18:57

3 Answers3

8

First you need to make sure you have the upstream remote repository set:

git remote add upstream git@github.com:networkx/networkx.git

Then You need to fetch upstream/master and then rebase on that. It's something along the lines of:

git fetch upstream
git checkout <feature-branch>
git rebase upstream/master

As git replays your work on top of upstream/master, conflicts will be raised and you'll have to dive into the files to resolve them. Then you:

git add <files that you fixed>
git rebase --continue
Paul H
  • 65,268
  • 20
  • 159
  • 136
8

Actually... you don't have anymore to pull and rebase locally.
You can resolve (simple) merge conflicts right form GitHub, since Dec. 2016.

See "Resolve simple merge conflicts on GitHub "

You can now resolve simple merge conflicts on GitHub right from your pull requests, saving you a trip to the command line and helping your team merge pull requests faster.

Demonstrating how to resolve a merge conflict

The new feature helps you resolve conflicts caused by competing line changes, like when people make different changes to the same line of the same file on different branches in your Git repository.
You'll still have to resolve other, more complicated conflicts locally on the command line.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    don't use this feature if you don't want to start the whole thing from the start. Sometimes when you press the commit button the whole thing freezes, and if you press back to previous page - on your mouse accidentally - or just reload the page you can start the whole thing from 0. – Random Dude Jan 13 '22 at 09:19
  • @RandomName Good point. That is unfortunate indeed. – VonC Jan 13 '22 at 09:38
6

Try running this to see what remotes you have set up:

git remote -v

If you don't already have a remote for the original repository you forked from in Github, you can add it as follows:

git remote add upstream https://github.com/networkx/networkx.git

This will name the remote upstream. After this, you can merge in the latest upstream into your branch and resolve your conflicts:

git fetch upstream
git merge upstream/master

If the first git remote -v command already showed a remote with that name, just use that instead of adding a new remote. Hope that helps.

Eddy R.
  • 1,089
  • 7
  • 12