We sometimes use SourceTree as client. It handles various line endings OK, but the diff tool it uses does not. It sees all lines ending in LF as one line.
As a result, we keep all source in our repository with CRLF.
I'm looking at installing a git client. I can't find the correct setting for TEXT or AUTOCRLF. It seems like they all want to "normalize" the file on check in to LF.
I want to Convert to CRLF on checkout; and either Convert to CRLF on checkin; or Do nothing on checkin;
The best I can find so far is -text: Do nothing on checkin or checkout;
Is there any hope?
Thanks, Brad.
Git's native end-of-line settings are LF, and I'm not aware of any way to alter that behavior aside from recompiling it from source. However, you can force checkouts to use CRLF, which requires the creation of a .gitattributes
file. For example:
# Force C# source files to be checked out using CRLF line endings,
# ignoring "core.eol" setting.
*.cs eol=crlf
# Don't apply CRLF conversion to PDF files, regardless of
# user settings including "core.autocrlf".
*.pdf -text
# All other files are subjected to the usual algorithm to determine
# whether a file is a binary file or a text file, respecting
# "core.eol" for all files detected as text files.
# "core.autocrlf", if set, will force the conversion to/from CRLF
# automatically as necessary for text files.
* text=auto
Note that if you created a new file with LF line endings (e.g. using Linux, Cygwin, or an application such as Notepad++ that defaults to LF line endings), you will get a warning when adding that file to the repository if it matches a pattern in the .gitattributes
file where eol=crlf
is used:
warning: LF will be replaced by CRLF in Example.cs.
The file will have its original line endings in your working directory.
Of course, if you later pull new changes, the original LF line endings will no longer be present.
Here's a list of the interactions between various EOL/text settings:
.gitattributes
file
eol=...
lf
and crlf
.core.eol
and core.autocrlf
.text
core.eol
and core.autocrlf
.text=auto
core.eol
and core.autocrlf
for text files.core.eol
and core.autocrlf
for binary files.-text
core.eol
and core.autocrlf
since they don't apply to binary files.core.autocrlf
configuration setting
input
: any text files checked in will undergo conversion from CRLF to the native LF.true
: any text files checked in/out undergo CRLF conversion.eol=...
rule applied to certain files in .gitattributes
.core.eol
configuration setting
native
(default): any text files checked out have native line endings (CRLF on Windows, LF elsewhere)lf
: any text files checked out have LF line endingscrlf
: any text files checked out have CRLF line endingscore.autocrlf
is set to true
, this setting is ignored.eol=...
rule applied to certain files in .gitattributes
.