Git插入了许多<<<<<错误消息进入我的源代码 [英] Git inserted many <<<<< error messages into my sourcecode

查看:52
本文介绍了Git插入了许多<<<<<错误消息进入我的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用Git还是很陌生,所以有很多事情让我逃脱了.昨天,我尝试执行 git revert 操作失败,并产生了一些有关合并或填充的错误.我找到了解决方法,方法是克隆存储库,然后使用

I'm very new to using Git, so many things escape me. Yesterday I tried to do a git revert operation which failed, and it generated some error about merging or stuff. I found a workaround this, by cloning my repository and then using

$ git reset --hard SHA1_HASH

$ git reset --hard SHA1_HASH

返回上一次提交.不幸的是,现在我的代码中充斥着许多其他内容,例如

to get back to a previous commit. Unfortunately, now my code is peppered with lots of additional stuff like

<<<<<<<<<<<< HEAD
//some stuff
=======
//other stuff
>>>>>>>>>>>> parent of 1ae3953... Removed duplicate folders

如何删除这些东西?我真的很难浏览所有文件并手动删除它们... Git有办法删除它吗?

How do I remove this stuff? I'm having a really hard time going through all my files and deleting them by hand... Is there a way for Git to remove it?

事实证明,在某些提交期间,标记已以某种方式成为我的代码的一部分.我如何确保将来在某些拉取或还原操作失败的情况下,Git不会将这些标记插入我的代码中?是否有某种-flag标记?

Turns out the marker became part of my code somehow during some commit. How do I ensure in the future, if some pull or revert failed, Git would not insert these markers into my code? Is there some kind of -flag for it?

推荐答案

这是一个合并冲突标记,当您执行git pull之类的操作时,将添加此标记,并且传入的更改无法与您自己的更改自动合并.它显示了您需要手动解决冲突的位置.

That's a merge conflict marker, which is added when you do something like a git pull and the incoming changes can't be merged automatically with your own changes. It shows you where you need to manually resolve a conflict.

git reset --hard不会添加这样的标记,它会重置所有内容以匹配您指定的提交.如果您在执行git reset --hard之后看到冲突标记,则可能是在过去的某个时候忽略了解决冲突,而无意间犯下了冲突.

git reset --hard doesn't add markers like that, it resets everything to match the commit you specified. If you see conflict markers after doing git reset --hard, you probably neglected to resolve a conflict at some point in the past, and inadvertently committed them.

这篇关于Git插入了许多&lt;&lt;&lt;&lt;&lt;错误消息进入我的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆