Can git's .gitattributes treat all files as binary except a few exceptions?
binary
is a macro setting the attribute crlf and diff (actually here unsetting them)
See "USING ATTRIBUTE MACROS" from the .gitattribute
man page.
Once an attribute is set or unset, if cannot be changed by a subsequent rule.
So you could try:
* -text
*.txt crlf diff
That way, crlf
and diff
being set for *.txt
files, they won't be unset by the binary macro for those same *.txt
files, while they will be unset for all the other files.
For LF or auto:
*.txt text eol=lf
#
*.txt text=auto
From the 2009 commit b9d14ff, those rules should go:
- from the more general ones
- to the more specific ones.
("a later line overrides an earlier line")
git has no concept of "binary" and "text" files. It's all defined as a set of attributes which designate how should we do merges, diffs, CR/LF conversions, handle whitespaces, apply filters and zillions of other things.
binary
and syntax like
*.o binary
is actually macro-based, i.e. binary
is a macro that expands to a whole lot of various attributes that designate merging, diffing, CR/LF handling, etc.
There is no text
macro as far as I see. binary
expands to -crlf -diff
, so disabling binary and going back to text-style processing seems to be crlf diff
.