Is there a way either in Atlassian SourceTree or with my current git host (BitBucket) to change the line endings globally for all my repositories.

I think they are currently set to Unix (I think I did this by accident) but I am developing solely on Windows. My IDE keeps giving me warning messages and errors about mixed line endings in my files and I'd like to fix it but every time I push my project to the cloud it gets changed back to Unix endings so even if I batch change the line endings they get reverted anyway.

1 Answer 1


You can configure the line ending handling per repository by adding a special .gitattributes file to the root folder of your Git repository. If this file is committed to the repository, it overrides the core.autocrlf setting of the individual developer.

In this file you can configure Git to auto detect the line endings.

Note:- Not all graphical Git tools support the .gitattributes file, for example the Eclipse IDE does currently not support it.

Here's an example .gitattributes file. You can use it as a template for your repositories:

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

You'll notice that files are matched--*.c, *.sln, *.png--, separated by a space, then given a setting--text, text eol=crlf, binary. We'll go over some possible settings below.

text=auto Git will handle the files in whatever way it thinks is best. This is a good default option.

text eol=crlf Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux. For example, here is a Windows project that enforces CRLF line endings.

text eol=lf Git will always convert line endings to LF on checkout. You should use this for files that must keep LF endings, even on Windows. For example, here is a project that enforces LF line endings.

binary Git will understand that the files specified are not text, and it should not try to change them. The binary setting is also an alias for -text -diff.

  • External links can become unavailable, in which case your answer would have little value. Please include the essential information in your answer and use the link for attribution and a source of further information. Thanks.
    – fixer1234
    Feb 26, 2015 at 14:51
  • Hope this includes the detail required
    – gpullen
    Feb 26, 2015 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.