Git如何从文件中删除冲突标记? [英] Git how to remove conflict markers from files?
问题描述
>>>>>>> master
.row
- @power.next_invoice.tap do |invoice|
%p
= link_to t(".postings"), postings_path
<<<<<<< HEAD
.span9{style: 'margin-top: 50px;'}
=======
.span9
>>>>>>> master
以某种方式将这些主注释和主注释/代码添加到了我在所有文件中的所有代码中. 如何删除它们?
Somehow these master and head comments/code have been added all over my code in all files. How do I remove them?
推荐答案
当您在git存储库中的两次提交之间存在合并冲突时,就会发生这种情况.
This happens when you have a merge conflict between two commits in your git repository.
您可以使用mergetool,也可以手动删除这些实例(如果您的编辑器允许搜索和替换,请搜索<<<<<<< HEAD
和>>>>>>> master
的实例以将其删除)
You can either use a mergetool, or you can manually delete these instances (if your editor allows for search and replace, search for instances of <<<<<<< HEAD
and >>>>>>> master
to delete them)
在您的示例中,我可以看到您在此处有重复的代码-
In your example, I can see there you have a duplicate code here -
<<<<<<< HEAD
.span9{style: 'margin-top: 50px;'}
=======
.span9
>>>>>>> master
您必须确定是否要使用.span9{style: 'margin-top: 50px;'}
或是否要.span9
(我假设您在其下有更多的CSS定义).并相应地删除其他选项. ======
也应删除.
You have to decide if your wan .span9{style: 'margin-top: 50px;'}
or if you want .span9
(I am assuming you have more css definitions below that). And delete the other option accordingly. ======
should also be removed.
一旦做出决定,就应该运行
Once you have made your decision, you should run
git status
这将显示您已经更新了此特定的css文件,并且可能还会有git创建的该文件的.orig
副本.删除.orig
文件,然后git add/commit完成合并冲突解决方案.
which will show you that you have updated this particular css file and chances are you will also have a .orig
copy of this file created by git. Delete the .orig
file, and git add/commit to complete your merge conflict resolution.
这篇关于Git如何从文件中删除冲突标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!