sorin sorin - 2 months ago 19
Git Question

How do I force git to use LF instead of CR+LF under windows?

I want to force git to checkout files under Windows using just

. I checked the two configuration options but I was not able to find the right combination of settings.

I want it to convert all files to
and keep the
on the files.

Remark: I used
autocrlf = input
but this just repairs the files when you commit them. I want to force it to get them using

Probably I wasn't so clear: the repository is already using
but the files checked out using msysgit are using
and I want to force msysgit to get them with
: forcing Unix line endings.

>git config --list | grep crlf


The OP added in his question:

the files checked out using msysgit are using CR+LF and I want to forge msysgit to get them with LF

A first simple step would still be in a .gitattributes file:

*.txt -crlf

, to avoid any crlf conversion for files with correct eol.

See Best practices for cross platform git config?

But a second more powerful step involves a gitattribute filter driver and add a smudge step

filter driver

Whenever you would update your working tree, a script could, only for the files you have specified in the .gitattributes, force the LF eol and any other formatting option you want to enforce.
If the "clear" script doesn't do anything, you will have (after commit) transformed your files, applying exactly the format you need them to follow.