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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With