Trouble merging upstream changes back into my branch

anonymous picture anonymous · Apr 24, 2011 · Viewed 92k times · Source

I'm running into conflicts while trying to merge upstream changes back into my branch and I'm not sure how to resolve them.

I created my own fork. I cloned it. I made changes to the branch on my fork, committed, and pushed. But then the main fork updated, and I tried to update my own fork by merging upstream in like so:

$ cd repo-name
$ git remote add upstream git://github.com/username/repo-name.git
$ git fetch upstream
$ git merge upstream/master

The merge says that there's some problem with a file and auto-merging doesn't work. It tells me to fix it myself and re-merge. So I actually went to the (upstream) repository on GitHub of the main fork and copied all the code of the new file into the file on my fork, and tried to merge again. Then, git gives me this error:

fatal: 'merge' is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm ' as appropriate to mark resolution and make a commit, or use 'git commit -a'.

Is there some argument I'm leaving out? Am I doing something stupid? What does it mean by "unmerged files?" Isn't the whole point of merging to merge files? Do I have to commit my changes before I merge?

Answer

Šimon Tóth picture Šimon Tóth · Apr 24, 2011

What you are seeing means that automatic merge could not resolve the conflicts in the files. You need to resolve these conflicts manually. Run git mergetool or git gui.