Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
854 views
in Technique[技术] by (71.8m points)

git - Trouble merging upstream changes back into my branch

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...