Is there a way to determine the line endings in a existing git repo?

U. N. Owen picture U. N. Owen · Aug 6, 2012 · Viewed 13.2k times · Source

Is there a way to determine the line endings in a existing git repository?

If I clone a existing repository how do I determine what core.autocrlf was used by the creator?

I'm still uncertain whats the best setting for core.autocrlf e.g on a windows box (since there are multiple opinions: Distributing git configuration with the code or https://help.github.com/articles/dealing-with-line-endings)

Bonus question: Can you determine on windows (with standard tools) if a repo has mixed line endings (by wrong core.autocrlf setting) through all commits?

Answer

robinst picture robinst · Aug 6, 2012

To check what line endings were actually committed in the repository (regardless of your core.autocrlf setting), try the following:

git grep -I --files-with-matches --perl-regexp '\r' HEAD

(-I means that binary files should not be looked at.)