my assumption is that only in batch files windows line endings should be allowed. Everywhere else should be used the git internal mechanic to recognize binary files and all other text files should enforce linux file endings. Can this be configured simple, i.e. without .gitattributes
and listing all kind of file types?
CodePudding user response:
Can this be configured without .gitattributes?
No, it has to be configured somewhere, and .gitattributes is the appropriate somewhere.
Can this be configured without listing all kind of file types?
Yes, you can use a pattern match of *
to match all files, and the special attribute text=auto
. Quoting the manual page for gitattributes:
When
text
is set to "auto", the path is marked for automatic end-of-line conversion. If Git decides that the content is text, its line endings are converted to LF on checkin. When the file has been committed with CRLF, no conversion is done.
Note also the order of precedence:
When more than one pattern matches the path, a later line overrides an earlier line. This overriding is done per attribute.
So all you need are two rules:
# Unless over-ridden, detect text files automatically, and use Unix line endings
* text=auto eol=lf
# Over-ride batch files to always be text, and use Windows line endings
*.bat text eol=crlf