如何解决由于删除分支中的文件而导致的合并冲突? [英] How do I fix a merge conflict due to removal of a file in a branch?

查看:783
本文介绍了如何解决由于删除分支中的文件而导致的合并冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个对话框,当我尝试将它合并到 master 分支中。有2个冲突。我不知道如何解决 CONFLICT(删除/修改)

  $ git checkout master 
$ git合并对话框
CONFLICT (删除/修改):res / layout / dialog_item.xml在对话框中删除并在HEAD中修改。 res / layout / dialog_item.xml的版本HEAD留在树中。
自动合并src / com / DialogAdapter.java
CONFLICT(内容):合并src / DialogAdapter.java中的冲突
自动合并失败;修复冲突,然后提交结果。

我打开了 src / DialogAdapter.java ,修复了冲突并做了一个 git add src / DialogAdapter.java 。我还需要做什么?

解决方案

冲突信息:

 
CONFLICT(删除/修改):res / layout / dialog_item.xml在对话框中删除并在HEAD中修改

表示在你正在合并的'dialog'分支中删除了 res / layout / dialog_item.xml ,但是在HEAD中(在你正在合并的分支中) 。



因此,您必须决定是否使用<$ c删除文件 $ c> git rm res / layout / dialog_item.xml





  • 使用 git add res / layout / dialog_item.xml 接受HEAD的版本(可能在编辑之后)



然后你用 git commit 结束合并。

>

请注意,git会警告你,你正在创建一个合并提交,在(不常用)的情况下,它是你不想要的。可能从案件不太罕见的日子开始。

I have create a dialog branch and when I try to merge it to master branch. There are 2 conflicts. I don't know how to resolve CONFLICT (delete/modify). Can you please tell me what to do?

$ git checkout master
$ git merge dialog
CONFLICT (delete/modify): res/layout/dialog_item.xml deleted in dialog and modified in HEAD. Version HEAD of res/layout/dialog_item.xml left in tree.
Auto-merging src/com/DialogAdapter.java
CONFLICT (content): Merge conflict in src/DialogAdapter.java
Automatic merge failed; fix conflicts and then commit the result.

I have opened src/DialogAdapter.java, fixed the conflict and did a git add src/DialogAdapter.java. What else do I need to do?

解决方案

The conflict message:

CONFLICT (delete/modify): res/layout/dialog_item.xml deleted in dialog and modified in HEAD

means that res/layout/dialog_item.xml was deleted in the 'dialog' branch you are merging, but was modified in HEAD (in the branch you are merging to).

So you have to decide whether

  • remove file using "git rm res/layout/dialog_item.xml"

or

  • accept version from HEAD (perhaps after editing it) with "git add res/layout/dialog_item.xml"

Then you finalize merge with "git commit".

Note that git will warn you that you are creating a merge commit, in the (rare) case where it is something you don't want. Probably remains from the days where said case was less rare.

这篇关于如何解决由于删除分支中的文件而导致的合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆