Information Technology Reference
In-Depth Information
bindir/ binary
*.xyz text
In general, the syntax of the
.gitattributes
file allows you to define a list of
attributes for every pattern:
pattern attribute-1 attribute-2 attribute-3 ...
Pattern defines which files should be affected by a rule. Here are four pattern ex-
amples:
*
# all files
*.txt
# all files ending with .txt
somedir/
# all files under somedir/ directory
readme.txt
# one file readme.txt
For every pattern you can apply the arbitrary number of attributes, as in:
*.txt
text -merge eol=crlf
This line defines a rule that will be used for all the files matching the
*.txt
pat-
tern. The rule consists of three entries:
text
-merge
eol=crlf
The first entry, which consists of a single word
text
, sets the
text
attribute for all
matching files. As a consequence all the
*.txt
files will be regarded as text files, and
therefore git will perform an end-of-line normalization on them.
The second entry, which consists of one word
merge
preceded with a dash, unsets
the
merge
attribute. It means that all
*.txt
files are to be merged as binary files.
The last rule sets the end-of-line characters that should be used during checkout.
The list of all available attributes is summarized in
Table 9-2
.