1

Something weird happened this morning when I did a commit. I got an error, said to pull, I then pushed and all the files with new changes now have comments such as:

<<<<<<< HEAD
=======
>>>>>>> d737b374ebaef4b0f7bd4e3b008e8c4740beca4c

They are in the repo that way. How can I recover my files without going through all of them and removing them manually?

And why the heck did this happen is a more important question. Renders the concept of versioning useless - just spent an hour cleaning this mess

cyberwombat
  • 38,105
  • 35
  • 175
  • 251

1 Answers1

0

just spent an hour cleaning this mess

It is a job for bfg then:

bfg --replace-text markers.txt  my-repo.git

With markers.txt including:

regex:<<<.*>>>=

That would get rid of all those merge markers in no time.

BFG repo cleaner is an alternative to git-filter-branch.

You would need to tweak a bit if you need to keep the HEAD part only:

# remove just <<< line
regex:<<<.*$
# remove everything after ===
regex:===.*>>>  
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250