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:

  • switch to experimental branch (git checkout experimental)
  • make a bunch of changes
  • commit it (git commit -a)
  • switch to master branch (git checkout master)
  • make some changes and commit there
  • switch back to experimental (git checkout experimental)
  • merge master change to experimental (git merge master)
  • there are some conflicts but after I resolve them, I did 'git add myfile'

  • 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?


    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.



    In case you ever get stuck during a merge/rebase you can always

    git reset --hard
    

    to restore your working to the state of the last commit. This will lose your changes from the working tree so if you had local modifications before the merge they will be gone after this—which is why it's advisable to not start a merge when you have local modifications. :)

    链接地址: http://www.djcxy.com/p/41714.html

    上一篇: Git在我的文件中将HEAD标记合并

    下一篇: 如何在解决我的合并冲突后完成合并?