How do I resolve conflicts with Git?

Neil G picture Neil G · Aug 6, 2015 · Viewed 7.7k times · Source

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.

Answer

Paul H picture Paul H · Aug 6, 2015

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

git remote add upstream [email protected]: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