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
809 views
in Technique[技术] by (71.8m points)

git - How do I finish the merge after resolving my merge conflicts?

I've read the Basic Branching and Merging section of the Git Community Book.

So I follow it and create one branch: experimental.

Then I:

  1. switch to experimental branch (git checkout experimental)
  2. make a bunch of changes
  3. commit it (git commit -a)
  4. switch to master branch (git checkout master)
  5. make some changes and commit there
  6. switch back to experimental (git checkout experimental)
  7. merge master change to experimental (git merge master)
  8. there are some conflicts but after I resolve them, I did 'git add myfile'

  9. And now i am stuck, I can't move back to master

when I do

 $ git checkout master
error: Entry 'res/layout/my_item.xml' would be overwritten by merge. Cannot merge.

and I did:

$ git rebase --abort

No rebase in progress?

and I did :

$  git add res/layout/socialhub_list_item.xml
$ git checkout master
error: Entry 'res/layout/my_item.xml' would be overwritten by merge. Cannot merge.

What can I do so that I can go back to my master branch?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

When there is a conflict during a merge, you have to finish the merge commit manually. It sounds like you've done the first two steps, to edit the files that conflicted and then run git add on them to mark them as resolved. Finally, you need to actually commit the merge with git commit. At that point you will be able to switch branches again.

Quick Tip: You can use git commit -am "your commit message" to perform add and commit operations on tracked files simultaneously. (Credit: @vaheeds)


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

1.4m articles

1.4m replys

5 comments

57.0k users

...