开发者

Git inserted many <<<<< error messages into my sourcecode

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

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

How do I remove this stuff? I'm having a really hard time going through all my fil开发者_JAVA技巧es and deleting them by hand... Is there a way for Git to remove it?

EDIT: 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?


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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜