3

我正在尝试从已删除某些已在目标分支中修改的文件的源分支合并。我想忽略删除并简单地接受目标分支已经拥有的内容。

当我:

git merge -s recursive -X ours master

的输出git status是:

# On branch nyap-artifactory
# Changes to be committed:
#
#   new file:   file-re-added-by-source-branch-that-should-be-deleted
#   modified:   file-modified-by-source-branch
#
# Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   deleted by them:    file-deleted-by-source-branch-that-should-be-kept

下一步是什么?

4

2 回答 2

2

您应该将文件重新添加到索引中:

git checkout HEAD -- file-deleted-by-source-branch-that-should-be-kept

并提交合并。

这样做是从nyap-artifactory分支获取最新版本。[*]


[*] (Agit reset -- file-deleted-by-source-branch-that-should-be-kept可能就足够了,但使用起来有点棘手,因为它不一定会更新工作树,并且具有足够强大的选项以意外丢失数据)。

于 2013-05-10T17:52:54.413 回答
1

git add 文件名并提交合并。类似的问题在这里有进一步的解释:git - merge conflict when local is deleted but file exists in remote

于 2013-05-10T17:50:07.747 回答