Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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 files 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?

like image 842
Cardin Avatar asked Jan 21 '11 03:01

Cardin


1 Answers

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.

like image 73
Wyzard Avatar answered Sep 17 '22 21:09

Wyzard