git 冲突 - 在 HEAD 中删除并在修订版中修改的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12809783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git conflict - file deleted in HEAD and modified in revision
提问by bsod99
Pretty new to git and have a bit of an issue i'm not sure how to fix. I mistakenly made a change to one file in a working copy and didn't commit the change. I then made changes to another copy and committed them - when I tried to pull the changes I unsurprisingly got an error saying my "local changes to the file would be overwritten by merge, aborting". So I removed the offending file using git rm, then used git add -u and committed the deletion. I then tried to pull in the latest copy and got the following. What's the best way to deal with this? grateful for any pointers
对 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.
采纳答案by j_mcnally
SO at this point do you have the file in the working copy that you pulled to?
那么此时您在工作副本中有该文件吗?
if so just delete it and recommit.
如果是这样,只需删除它并重新提交。
回答by thSoft
If you now do git status
, its output contains:
如果你现在这样做git status
,它的输出包含:
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
If you git rm
them, a needs merge
warning will be output but nevertheless the removal will succeed, then you can commit the modifications - this will be the "merge commit".
如果你git rm
他们,一个needs merge
警告将被输出,但删除会成功,然后你可以提交修改 - 这将是“合并提交”。
回答by PJ Brunet
Had a similar problem with a cheesy WordPress host. Try this..
一个俗气的 WordPress 主机也有类似的问题。尝试这个..
git log --follow -- readme.html
Note the commit id of the last time that file existed (like before you deleted it.) Now you want to "checkout" that file from git.
请注意该文件上次存在时的提交 ID(就像您删除它之前一样)。现在您想从 git 中“检出”该文件。
git checkout (commit id) readme.html
Then add, commit, push, etc. Worked for me!
然后添加、提交、推送等。对我来说有效!