【问题标题】:git conflict - file deleted in HEAD and modified in revisiongit 冲突 - 文件在 HEAD 中删除并在修订中修改
【发布时间】:2019-11-23 05:34:01
【问题描述】:

对 git 很陌生,有一些问题我不知道如何解决。我错误地更改了工作副本中的一个文件并且没有提交更改。然后,我对另一个副本进行了更改并提交了它们——当我尝试拉取更改时,不出所料地收到一个错误,说我的“对文件的本地更改将被合并、中止覆盖”。所以我使用 git rm 删除了有问题的文件,然后使用 git add -u 并提交了删除。然后我试图拉入最新的副本并得到以下内容。处理这个问题的最佳方法是什么?感谢任何指点

CONFLICT (delete/modify): wp-content/plugins/wp-flash-countdown/xml_option_.xml deleted in HEAD and modified in ba878ab1efe3a039961a446c490d5c93a2bc22e1. Version ba878ab1efe3a039961a446c490d5c93a2bc22e1 of wp-content/plugins/wp-flash-countdown/xml_option_.xml left in tree.
Automatic merge failed; fix conflicts and then commit the result.

【问题讨论】:

标签: git


【解决方案1】:

如果你现在做git status,它的输出包含:

# Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)

如果您git rm 他们,将输出needs merge 警告,但删除将成功,然后您可以提交修改 - 这将是“合并提交”。

【讨论】:

    【解决方案2】:

    那么此时您是否在您提取到的工作副本中拥有该文件?

    如果是这样,请将其删除并重新提交。

    【讨论】:

    • 我刚刚尝试过,重新提交然后再次拉取 - 这次得到 Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm &lt;file&gt;' - 它还列为添加文件,我刚刚从该工作副本中删除,因为它们没有被跟踪
    • 好的,所以这只是导致问题的一个文件 - 尝试使用 git rm 删除但出现“需要合并”错误
    • 最后,用你的解决方案和我的一些不必要的额外步骤,把它整理好了!
    【解决方案3】:

    与俗气的 WordPress 主机有类似的问题。试试这个..

    git log --follow -- readme.html
    

    记下该文件最后一次存在的提交 ID(就像在您删除它之前一样)。现在您想从 git 中“签出”该文件。

    git checkout (commit id) readme.html
    

    然后添加、提交、推送等。为我工作!

    【讨论】:

    • 这对我很有效,谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-27
    • 2015-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多