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

Viewed 15706

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?

4 Answers

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

git ls-files --eol

# for a given file:
git -c color.diff.whitespace="red reverse" diff -R -- afile

In Windows, just run the below command from the command prompt:

git config --list

This will list all the git configuration variables.

If you want to get the individual config setting (e.g. for core.autocrlf), run the following command on the windows command prompt:

git config --get core.autocrlf

This will either give you a "true" OR "false" value.

If you wish to change this, edit C:\ProgramData\Git\config file, and change the value from false to true

Note: This only applies for Windows operating systems.

Related