In our git repo our files sometimes end up with additional carriage returns at the end of the line. When I view the files in vim I see;
<?xml version="1.0" encoding="utf-8"?>^M
<Root>^M
<Child/>^M
</Root>^M
These extra ^M
will be on every line in the file. This causes problems when we merge because the other side of the merge will not have the additional ^M
and we get many merge conflicts. Passing options to ignore white space to git merge
doesn't seem to help, it still conflicts on the whole file.
We use git config core.autoclrf true
.
I need two things;
- How do a search for all of these
^M
in my repo? Such that I can use somegit ls-files | grep <filter here> | sed 's/^M//'
to get rid of them. - How do I identify how they're being introduced?