how to find crlf line separators with git?

You could use git grep via the command line to search for files containing the windows style newline characters.

Using the git bash you can find all files which contain a \r character via the following command (bash only!):

git grep -Il $'\r'

Or alternativly (which should work for all shell types – except windows ones):

git grep -Il '<CTRL + M>'

This will actually display as a newline in your shell, but as long as you wrap it into quotes it will work.

And finally for the windows CLI (tested with CMD and PowerShell):

git grep -Il "\r"

Used options

  • -I excludes binary files from the match
  • -l shows only the file names with matches, rather than all matches

Also, if you want to restrict your search on a number of files you can use the --cached option, which will only search in files you have on your index.

You can read the documentation for more information.

Leave a Comment