我正在尝试从已删除目标分支中已修改的某些文件的源分支进行合并。我想忽略删除并简单地接受目标分支已有的内容。
当我:
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
下一步是什么?
答案 0 :(得分:2)
您只需将文件重新添加到索引:
git checkout HEAD -- file-deleted-by-source-branch-that-should-be-kept
并提交合并。
这样做是从nyap-artifactory
分支获取最新版本。 [*]
[*](A git reset -- file-deleted-by-source-branch-that-should-be-kept
可能已经足够了,但使用起来有点棘手,因为它不一定更新工作树,并且具有足够强大的选项来意外丢失数据)。
答案 1 :(得分:1)
git add file-name并提交合并。 类似的问题在这里有进一步的解释:git - merge conflict when local is deleted but file exists in remote