1GITATTRIBUTES(5)                  Git Manual                  GITATTRIBUTES(5)
2
3
4

NAME

6       gitattributes - defining attributes per path
7

SYNOPSIS

9       $GIT_DIR/info/attributes, .gitattributes
10

DESCRIPTION

12       A gitattributes file is a simple text file that gives attributes to
13       pathnames.
14
15       Each line in gitattributes file is of form:
16
17           pattern attr1 attr2 ...
18
19       That is, a pattern followed by an attributes list, separated by
20       whitespaces. When the pattern matches the path in question, the
21       attributes listed on the line are given to the path.
22
23       Each attribute can be in one of these states for a given path:
24
25       Set
26           The path has the attribute with special value "true"; this is
27           specified by listing only the name of the attribute in the
28           attribute list.
29
30       Unset
31           The path has the attribute with special value "false"; this is
32           specified by listing the name of the attribute prefixed with a dash
33           - in the attribute list.
34
35       Set to a value
36           The path has the attribute with specified string value; this is
37           specified by listing the name of the attribute followed by an equal
38           sign = and its value in the attribute list.
39
40       Unspecified
41           No pattern matches the path, and nothing says if the path has or
42           does not have the attribute, the attribute for the path is said to
43           be Unspecified.
44
45       When more than one pattern matches the path, a later line overrides an
46       earlier line. This overriding is done per attribute. The rules how the
47       pattern matches paths are the same as in .gitignore files; see
48       gitignore(5). Unlike .gitignore, negative patterns are forbidden.
49
50       When deciding what attributes are assigned to a path, Git consults
51       $GIT_DIR/info/attributes file (which has the highest precedence),
52       .gitattributes file in the same directory as the path in question, and
53       its parent directories up to the toplevel of the work tree (the further
54       the directory that contains .gitattributes is from the path in
55       question, the lower its precedence). Finally global and system-wide
56       files are considered (they have the lowest precedence).
57
58       When the .gitattributes file is missing from the work tree, the path in
59       the index is used as a fall-back. During checkout process,
60       .gitattributes in the index is used and then the file in the working
61       tree is used as a fall-back.
62
63       If you wish to affect only a single repository (i.e., to assign
64       attributes to files that are particular to one user’s workflow for that
65       repository), then attributes should be placed in the
66       $GIT_DIR/info/attributes file. Attributes which should be
67       version-controlled and distributed to other repositories (i.e.,
68       attributes of interest to all users) should go into .gitattributes
69       files. Attributes that should affect all repositories for a single user
70       should be placed in a file specified by the core.attributesfile
71       configuration option (see git-config(1)). Its default value is
72       $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME is either not set
73       or empty, $HOME/.config/git/attributes is used instead. Attributes for
74       all users on a system should be placed in the
75       $(prefix)/etc/gitattributes file.
76
77       Sometimes you would need to override an setting of an attribute for a
78       path to Unspecified state. This can be done by listing the name of the
79       attribute prefixed with an exclamation point !.
80

EFFECTS

82       Certain operations by Git can be influenced by assigning particular
83       attributes to a path. Currently, the following operations are
84       attributes-aware.
85
86   Checking-out and checking-in
87       These attributes affect how the contents stored in the repository are
88       copied to the working tree files when commands such as git checkout and
89       git merge run. They also affect how Git stores the contents you prepare
90       in the working tree in the repository upon git add and git commit.
91
92       text
93           This attribute enables and controls end-of-line normalization. When
94           a text file is normalized, its line endings are converted to LF in
95           the repository. To control what line ending style is used in the
96           working directory, use the eol attribute for a single file and the
97           core.eol configuration variable for all text files.
98
99           Set
100               Setting the text attribute on a path enables end-of-line
101               normalization and marks the path as a text file. End-of-line
102               conversion takes place without guessing the content type.
103
104           Unset
105               Unsetting the text attribute on a path tells Git not to attempt
106               any end-of-line conversion upon checkin or checkout.
107
108           Set to string value "auto"
109               When text is set to "auto", the path is marked for automatic
110               end-of-line normalization. If Git decides that the content is
111               text, its line endings are normalized to LF on checkin.
112
113           Unspecified
114               If the text attribute is unspecified, Git uses the
115               core.autocrlf configuration variable to determine if the file
116               should be converted.
117
118           Any other value causes Git to act as if text has been left
119           unspecified.
120
121       eol
122           This attribute sets a specific line-ending style to be used in the
123           working directory. It enables end-of-line normalization without any
124           content checks, effectively setting the text attribute.
125
126           Set to string value "crlf"
127               This setting forces Git to normalize line endings for this file
128               on checkin and convert them to CRLF when the file is checked
129               out.
130
131           Set to string value "lf"
132               This setting forces Git to normalize line endings to LF on
133               checkin and prevents conversion to CRLF when the file is
134               checked out.
135
136       Backwards compatibility with crlf attribute
137           For backwards compatibility, the crlf attribute is interpreted as
138           follows:
139
140               crlf            text
141               -crlf           -text
142               crlf=input      eol=lf
143
144
145       End-of-line conversion
146           While Git normally leaves file contents alone, it can be configured
147           to normalize line endings to LF in the repository and, optionally,
148           to convert them to CRLF when files are checked out.
149
150           Here is an example that will make Git normalize .txt, .vcproj and
151           .sh files, ensure that .vcproj files have CRLF and .sh files have
152           LF in the working directory, and prevent .jpg files from being
153           normalized regardless of their content.
154
155               *.txt           text
156               *.vcproj        eol=crlf
157               *.sh            eol=lf
158               *.jpg           -text
159
160
161           Other source code management systems normalize all text files in
162           their repositories, and there are two ways to enable similar
163           automatic normalization in Git.
164
165           If you simply want to have CRLF line endings in your working
166           directory regardless of the repository you are working with, you
167           can set the config variable "core.autocrlf" without changing any
168           attributes.
169
170               [core]
171                       autocrlf = true
172
173
174           This does not force normalization of all text files, but does
175           ensure that text files that you introduce to the repository have
176           their line endings normalized to LF when they are added, and that
177           files that are already normalized in the repository stay
178           normalized.
179
180           If you want to interoperate with a source code management system
181           that enforces end-of-line normalization, or you simply want all
182           text files in your repository to be normalized, you should instead
183           set the text attribute to "auto" for all files.
184
185               *       text=auto
186
187
188           This ensures that all files that Git considers to be text will have
189           normalized (LF) line endings in the repository. The core.eol
190           configuration variable controls which line endings Git will use for
191           normalized files in your working directory; the default is to use
192           the native line ending for your platform, or CRLF if core.autocrlf
193           is set.
194
195               Note
196               When text=auto normalization is enabled in an existing
197               repository, any text files containing CRLFs should be
198               normalized. If they are not they will be normalized the next
199               time someone tries to change them, causing unfortunate
200               misattribution. From a clean working directory:
201
202               $ echo "* text=auto" >>.gitattributes
203               $ rm .git/index     # Remove the index to force Git to
204               $ git reset         # re-scan the working directory
205               $ git status        # Show files that will be normalized
206               $ git add -u
207               $ git add .gitattributes
208               $ git commit -m "Introduce end-of-line normalization"
209
210
211           If any files that should not be normalized show up in git status,
212           unset their text attribute before running git add -u.
213
214               manual.pdf      -text
215
216
217           Conversely, text files that Git does not detect can have
218           normalization enabled manually.
219
220               weirdchars.txt  text
221
222
223           If core.safecrlf is set to "true" or "warn", Git verifies if the
224           conversion is reversible for the current setting of core.autocrlf.
225           For "true", Git rejects irreversible conversions; for "warn", Git
226           only prints a warning but accepts an irreversible conversion. The
227           safety triggers to prevent such a conversion done to the files in
228           the work tree, but there are a few exceptions. Even though...
229
230           ·   git add itself does not touch the files in the work tree, the
231               next checkout would, so the safety triggers;
232
233           ·   git apply to update a text file with a patch does touch the
234               files in the work tree, but the operation is about text files
235               and CRLF conversion is about fixing the line ending
236               inconsistencies, so the safety does not trigger;
237
238           ·   git diff itself does not touch the files in the work tree, it
239               is often run to inspect the changes you intend to next git add.
240               To catch potential problems early, safety triggers.
241
242       ident
243           When the attribute ident is set for a path, Git replaces $Id$ in
244           the blob object with $Id:, followed by the 40-character hexadecimal
245           blob object name, followed by a dollar sign $ upon checkout. Any
246           byte sequence that begins with $Id: and ends with $ in the worktree
247           file is replaced with $Id$ upon check-in.
248
249       filter
250           A filter attribute can be set to a string value that names a filter
251           driver specified in the configuration.
252
253           A filter driver consists of a clean command and a smudge command,
254           either of which can be left unspecified. Upon checkout, when the
255           smudge command is specified, the command is fed the blob object
256           from its standard input, and its standard output is used to update
257           the worktree file. Similarly, the clean command is used to convert
258           the contents of worktree file upon checkin.
259
260           One use of the content filtering is to massage the content into a
261           shape that is more convenient for the platform, filesystem, and the
262           user to use. For this mode of operation, the key phrase here is
263           "more convenient" and not "turning something unusable into usable".
264           In other words, the intent is that if someone unsets the filter
265           driver definition, or does not have the appropriate filter program,
266           the project should still be usable.
267
268           Another use of the content filtering is to store the content that
269           cannot be directly used in the repository (e.g. a UUID that refers
270           to the true content stored outside Git, or an encrypted content)
271           and turn it into a usable form upon checkout (e.g. download the
272           external content, or decrypt the encrypted content).
273
274           These two filters behave differently, and by default, a filter is
275           taken as the former, massaging the contents into more convenient
276           shape. A missing filter driver definition in the config, or a
277           filter driver that exits with a non-zero status, is not an error
278           but makes the filter a no-op passthru.
279
280           You can declare that a filter turns a content that by itself is
281           unusable into a usable content by setting the
282           filter.<driver>.required configuration variable to true.
283
284           For example, in .gitattributes, you would assign the filter
285           attribute for paths.
286
287               *.c     filter=indent
288
289
290           Then you would define a "filter.indent.clean" and
291           "filter.indent.smudge" configuration in your .git/config to specify
292           a pair of commands to modify the contents of C programs when the
293           source files are checked in ("clean" is run) and checked out (no
294           change is made because the command is "cat").
295
296               [filter "indent"]
297                       clean = indent
298                       smudge = cat
299
300
301           For best results, clean should not alter its output further if it
302           is run twice ("clean→clean" should be equivalent to "clean"), and
303           multiple smudge commands should not alter clean's output
304           ("smudge→smudge→clean" should be equivalent to "clean"). See the
305           section on merging below.
306
307           The "indent" filter is well-behaved in this regard: it will not
308           modify input that is already correctly indented. In this case, the
309           lack of a smudge filter means that the clean filter must accept its
310           own output without modifying it.
311
312           If a filter must succeed in order to make the stored contents
313           usable, you can declare that the filter is required, in the
314           configuration:
315
316               [filter "crypt"]
317                       clean = openssl enc ...
318                       smudge = openssl enc -d ...
319                       required
320
321
322           Sequence "%f" on the filter command line is replaced with the name
323           of the file the filter is working on. A filter might use this in
324           keyword substitution. For example:
325
326               [filter "p4"]
327                       clean = git-p4-filter --clean %f
328                       smudge = git-p4-filter --smudge %f
329
330
331       Interaction between checkin/checkout attributes
332           In the check-in codepath, the worktree file is first converted with
333           filter driver (if specified and corresponding driver defined), then
334           the result is processed with ident (if specified), and then finally
335           with text (again, if specified and applicable).
336
337           In the check-out codepath, the blob content is first converted with
338           text, and then ident and fed to filter.
339
340       Merging branches with differing checkin/checkout attributes
341           If you have added attributes to a file that cause the canonical
342           repository format for that file to change, such as adding a
343           clean/smudge filter or text/eol/ident attributes, merging anything
344           where the attribute is not in place would normally cause merge
345           conflicts.
346
347           To prevent these unnecessary merge conflicts, Git can be told to
348           run a virtual check-out and check-in of all three stages of a file
349           when resolving a three-way merge by setting the merge.renormalize
350           configuration variable. This prevents changes caused by check-in
351           conversion from causing spurious merge conflicts when a converted
352           file is merged with an unconverted file.
353
354           As long as a "smudge→clean" results in the same output as a "clean"
355           even on files that are already smudged, this strategy will
356           automatically resolve all filter-related conflicts. Filters that do
357           not act in this way may cause additional merge conflicts that must
358           be resolved manually.
359
360   Generating diff text
361       diff
362           The attribute diff affects how Git generates diffs for particular
363           files. It can tell Git whether to generate a textual patch for the
364           path or to treat the path as a binary file. It can also affect what
365           line is shown on the hunk header @@ -k,l +n,m @@ line, tell Git to
366           use an external command to generate the diff, or ask Git to convert
367           binary files to a text format before generating the diff.
368
369           Set
370               A path to which the diff attribute is set is treated as text,
371               even when they contain byte values that normally never appear
372               in text files, such as NUL.
373
374           Unset
375               A path to which the diff attribute is unset will generate
376               Binary files differ (or a binary patch, if binary patches are
377               enabled).
378
379           Unspecified
380               A path to which the diff attribute is unspecified first gets
381               its contents inspected, and if it looks like text, it is
382               treated as text. Otherwise it would generate Binary files
383               differ.
384
385           String
386               Diff is shown using the specified diff driver. Each driver may
387               specify one or more options, as described in the following
388               section. The options for the diff driver "foo" are defined by
389               the configuration variables in the "diff.foo" section of the
390               Git config file.
391
392       Defining an external diff driver
393           The definition of a diff driver is done in gitconfig, not
394           gitattributes file, so strictly speaking this manual page is a
395           wrong place to talk about it. However...
396
397           To define an external diff driver jcdiff, add a section to your
398           $GIT_DIR/config file (or $HOME/.gitconfig file) like this:
399
400               [diff "jcdiff"]
401                       command = j-c-diff
402
403
404           When Git needs to show you a diff for the path with diff attribute
405           set to jcdiff, it calls the command you specified with the above
406           configuration, i.e. j-c-diff, with 7 parameters, just like
407           GIT_EXTERNAL_DIFF program is called. See git(1) for details.
408
409       Defining a custom hunk-header
410           Each group of changes (called a "hunk") in the textual diff output
411           is prefixed with a line of the form:
412
413               @@ -k,l +n,m @@ TEXT
414
415           This is called a hunk header. The "TEXT" portion is by default a
416           line that begins with an alphabet, an underscore or a dollar sign;
417           this matches what GNU diff -p output uses. This default selection
418           however is not suited for some contents, and you can use a
419           customized pattern to make a selection.
420
421           First, in .gitattributes, you would assign the diff attribute for
422           paths.
423
424               *.tex   diff=tex
425
426
427           Then, you would define a "diff.tex.xfuncname" configuration to
428           specify a regular expression that matches a line that you would
429           want to appear as the hunk header "TEXT". Add a section to your
430           $GIT_DIR/config file (or $HOME/.gitconfig file) like this:
431
432               [diff "tex"]
433                       xfuncname = "^(\\\\(sub)*section\\{.*)$"
434
435
436           Note. A single level of backslashes are eaten by the configuration
437           file parser, so you would need to double the backslashes; the
438           pattern above picks a line that begins with a backslash, and zero
439           or more occurrences of sub followed by section followed by open
440           brace, to the end of line.
441
442           There are a few built-in patterns to make this easier, and tex is
443           one of them, so you do not have to write the above in your
444           configuration file (you still need to enable this with the
445           attribute mechanism, via .gitattributes). The following built in
446           patterns are available:
447
448           ·   ada suitable for source code in the Ada language.
449
450           ·   bibtex suitable for files with BibTeX coded references.
451
452           ·   cpp suitable for source code in the C and C++ languages.
453
454           ·   csharp suitable for source code in the C# language.
455
456           ·   fortran suitable for source code in the Fortran language.
457
458           ·   html suitable for HTML/XHTML documents.
459
460           ·   java suitable for source code in the Java language.
461
462           ·   matlab suitable for source code in the MATLAB language.
463
464           ·   objc suitable for source code in the Objective-C language.
465
466           ·   pascal suitable for source code in the Pascal/Delphi language.
467
468           ·   perl suitable for source code in the Perl language.
469
470           ·   php suitable for source code in the PHP language.
471
472           ·   python suitable for source code in the Python language.
473
474           ·   ruby suitable for source code in the Ruby language.
475
476           ·   tex suitable for source code for LaTeX documents.
477
478       Customizing word diff
479           You can customize the rules that git diff --word-diff uses to split
480           words in a line, by specifying an appropriate regular expression in
481           the "diff.*.wordRegex" configuration variable. For example, in TeX
482           a backslash followed by a sequence of letters forms a command, but
483           several such commands can be run together without intervening
484           whitespace. To separate them, use a regular expression in your
485           $GIT_DIR/config file (or $HOME/.gitconfig file) like this:
486
487               [diff "tex"]
488                       wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"
489
490
491           A built-in pattern is provided for all languages listed in the
492           previous section.
493
494       Performing text diffs of binary files
495           Sometimes it is desirable to see the diff of a text-converted
496           version of some binary files. For example, a word processor
497           document can be converted to an ASCII text representation, and the
498           diff of the text shown. Even though this conversion loses some
499           information, the resulting diff is useful for human viewing (but
500           cannot be applied directly).
501
502           The textconv config option is used to define a program for
503           performing such a conversion. The program should take a single
504           argument, the name of a file to convert, and produce the resulting
505           text on stdout.
506
507           For example, to show the diff of the exif information of a file
508           instead of the binary information (assuming you have the exif tool
509           installed), add the following section to your $GIT_DIR/config file
510           (or $HOME/.gitconfig file):
511
512               [diff "jpg"]
513                       textconv = exif
514
515
516               Note
517               The text conversion is generally a one-way conversion; in this
518               example, we lose the actual image contents and focus just on
519               the text data. This means that diffs generated by textconv are
520               not suitable for applying. For this reason, only git diff and
521               the git log family of commands (i.e., log, whatchanged, show)
522               will perform text conversion. git format-patch will never
523               generate this output. If you want to send somebody a
524               text-converted diff of a binary file (e.g., because it quickly
525               conveys the changes you have made), you should generate it
526               separately and send it as a comment in addition to the usual
527               binary diff that you might send.
528
529           Because text conversion can be slow, especially when doing a large
530           number of them with git log -p, Git provides a mechanism to cache
531           the output and use it in future diffs. To enable caching, set the
532           "cachetextconv" variable in your diff driver’s config. For example:
533
534               [diff "jpg"]
535                       textconv = exif
536                       cachetextconv = true
537
538
539           This will cache the result of running "exif" on each blob
540           indefinitely. If you change the textconv config variable for a diff
541           driver, Git will automatically invalidate the cache entries and
542           re-run the textconv filter. If you want to invalidate the cache
543           manually (e.g., because your version of "exif" was updated and now
544           produces better output), you can remove the cache manually with git
545           update-ref -d refs/notes/textconv/jpg (where "jpg" is the name of
546           the diff driver, as in the example above).
547
548       Choosing textconv versus external diff
549           If you want to show differences between binary or
550           specially-formatted blobs in your repository, you can choose to use
551           either an external diff command, or to use textconv to convert them
552           to a diff-able text format. Which method you choose depends on your
553           exact situation.
554
555           The advantage of using an external diff command is flexibility. You
556           are not bound to find line-oriented changes, nor is it necessary
557           for the output to resemble unified diff. You are free to locate and
558           report changes in the most appropriate way for your data format.
559
560           A textconv, by comparison, is much more limiting. You provide a
561           transformation of the data into a line-oriented text format, and
562           Git uses its regular diff tools to generate the output. There are
563           several advantages to choosing this method:
564
565            1. Ease of use. It is often much simpler to write a binary to text
566               transformation than it is to perform your own diff. In many
567               cases, existing programs can be used as textconv filters (e.g.,
568               exif, odt2txt).
569
570            2. Git diff features. By performing only the transformation step
571               yourself, you can still utilize many of Git’s diff features,
572               including colorization, word-diff, and combined diffs for
573               merges.
574
575            3. Caching. Textconv caching can speed up repeated diffs, such as
576               those you might trigger by running git log -p.
577
578       Marking files as binary
579           Git usually guesses correctly whether a blob contains text or
580           binary data by examining the beginning of the contents. However,
581           sometimes you may want to override its decision, either because a
582           blob contains binary data later in the file, or because the
583           content, while technically composed of text characters, is opaque
584           to a human reader. For example, many postscript files contain only
585           ascii characters, but produce noisy and meaningless diffs.
586
587           The simplest way to mark a file as binary is to unset the diff
588           attribute in the .gitattributes file:
589
590               *.ps -diff
591
592
593           This will cause Git to generate Binary files differ (or a binary
594           patch, if binary patches are enabled) instead of a regular diff.
595
596           However, one may also want to specify other diff driver attributes.
597           For example, you might want to use textconv to convert postscript
598           files to an ascii representation for human viewing, but otherwise
599           treat them as binary files. You cannot specify both -diff and
600           diff=ps attributes. The solution is to use the diff.*.binary config
601           option:
602
603               [diff "ps"]
604                 textconv = ps2ascii
605                 binary = true
606
607
608   Performing a three-way merge
609       merge
610           The attribute merge affects how three versions of a file are merged
611           when a file-level merge is necessary during git merge, and other
612           commands such as git revert and git cherry-pick.
613
614           Set
615               Built-in 3-way merge driver is used to merge the contents in a
616               way similar to merge command of RCS suite. This is suitable for
617               ordinary text files.
618
619           Unset
620               Take the version from the current branch as the tentative merge
621               result, and declare that the merge has conflicts. This is
622               suitable for binary files that do not have a well-defined merge
623               semantics.
624
625           Unspecified
626               By default, this uses the same built-in 3-way merge driver as
627               is the case when the merge attribute is set. However, the
628               merge.default configuration variable can name different merge
629               driver to be used with paths for which the merge attribute is
630               unspecified.
631
632           String
633               3-way merge is performed using the specified custom merge
634               driver. The built-in 3-way merge driver can be explicitly
635               specified by asking for "text" driver; the built-in "take the
636               current branch" driver can be requested with "binary".
637
638       Built-in merge drivers
639           There are a few built-in low-level merge drivers defined that can
640           be asked for via the merge attribute.
641
642           text
643               Usual 3-way file level merge for text files. Conflicted regions
644               are marked with conflict markers <<<<<<<, ======= and >>>>>>>.
645               The version from your branch appears before the ======= marker,
646               and the version from the merged branch appears after the
647               ======= marker.
648
649           binary
650               Keep the version from your branch in the work tree, but leave
651               the path in the conflicted state for the user to sort out.
652
653           union
654               Run 3-way file level merge for text files, but take lines from
655               both versions, instead of leaving conflict markers. This tends
656               to leave the added lines in the resulting file in random order
657               and the user should verify the result. Do not use this if you
658               do not understand the implications.
659
660       Defining a custom merge driver
661           The definition of a merge driver is done in the .git/config file,
662           not in the gitattributes file, so strictly speaking this manual
663           page is a wrong place to talk about it. However...
664
665           To define a custom merge driver filfre, add a section to your
666           $GIT_DIR/config file (or $HOME/.gitconfig file) like this:
667
668               [merge "filfre"]
669                       name = feel-free merge driver
670                       driver = filfre %O %A %B
671                       recursive = binary
672
673
674           The merge.*.name variable gives the driver a human-readable name.
675
676           The ‘merge.*.driver` variable’s value is used to construct a
677           command to run to merge ancestor’s version (%O), current version
678           (%A) and the other branches’ version (%B). These three tokens are
679           replaced with the names of temporary files that hold the contents
680           of these versions when the command line is built. Additionally, %L
681           will be replaced with the conflict marker size (see below).
682
683           The merge driver is expected to leave the result of the merge in
684           the file named with %A by overwriting it, and exit with zero status
685           if it managed to merge them cleanly, or non-zero if there were
686           conflicts.
687
688           The merge.*.recursive variable specifies what other merge driver to
689           use when the merge driver is called for an internal merge between
690           common ancestors, when there are more than one. When left
691           unspecified, the driver itself is used for both internal merge and
692           the final merge.
693
694       conflict-marker-size
695           This attribute controls the length of conflict markers left in the
696           work tree file during a conflicted merge. Only setting to the value
697           to a positive integer has any meaningful effect.
698
699           For example, this line in .gitattributes can be used to tell the
700           merge machinery to leave much longer (instead of the usual
701           7-character-long) conflict markers when merging the file
702           Documentation/git-merge.txt results in a conflict.
703
704               Documentation/git-merge.txt     conflict-marker-size=32
705
706
707   Checking whitespace errors
708       whitespace
709           The core.whitespace configuration variable allows you to define
710           what diff and apply should consider whitespace errors for all paths
711           in the project (See git-config(1)). This attribute gives you finer
712           control per path.
713
714           Set
715               Notice all types of potential whitespace errors known to Git.
716               The tab width is taken from the value of the core.whitespace
717               configuration variable.
718
719           Unset
720               Do not notice anything as error.
721
722           Unspecified
723               Use the value of the core.whitespace configuration variable to
724               decide what to notice as error.
725
726           String
727               Specify a comma separate list of common whitespace problems to
728               notice in the same format as the core.whitespace configuration
729               variable.
730
731   Creating an archive
732       export-ignore
733           Files and directories with the attribute export-ignore won’t be
734           added to archive files.
735
736       export-subst
737           If the attribute export-subst is set for a file then Git will
738           expand several placeholders when adding this file to an archive.
739           The expansion depends on the availability of a commit ID, i.e., if
740           git-archive(1) has been given a tree instead of a commit or a tag
741           then no replacement will be done. The placeholders are the same as
742           those for the option --pretty=format: of git-log(1), except that
743           they need to be wrapped like this: $Format:PLACEHOLDERS$ in the
744           file. E.g. the string $Format:%H$ will be replaced by the commit
745           hash.
746
747   Packing objects
748       delta
749           Delta compression will not be attempted for blobs for paths with
750           the attribute delta set to false.
751
752   Viewing files in GUI tools
753       encoding
754           The value of this attribute specifies the character encoding that
755           should be used by GUI tools (e.g. gitk(1) and git-gui(1)) to
756           display the contents of the relevant file. Note that due to
757           performance considerations gitk(1) does not use this attribute
758           unless you manually enable per-file encodings in its options.
759
760           If this attribute is not set or has an invalid value, the value of
761           the gui.encoding configuration variable is used instead (See git-
762           config(1)).
763

USING MACRO ATTRIBUTES

765       You do not want any end-of-line conversions applied to, nor textual
766       diffs produced for, any binary file you track. You would need to
767       specify e.g.
768
769           *.jpg -text -diff
770
771
772       but that may become cumbersome, when you have many attributes. Using
773       macro attributes, you can define an attribute that, when set, also sets
774       or unsets a number of other attributes at the same time. The system
775       knows a built-in macro attribute, binary:
776
777           *.jpg binary
778
779
780       Setting the "binary" attribute also unsets the "text" and "diff"
781       attributes as above. Note that macro attributes can only be "Set",
782       though setting one might have the effect of setting or unsetting other
783       attributes or even returning other attributes to the "Unspecified"
784       state.
785

DEFINING MACRO ATTRIBUTES

787       Custom macro attributes can be defined only in the .gitattributes file
788       at the toplevel (i.e. not in any subdirectory). The built-in macro
789       attribute "binary" is equivalent to:
790
791           [attr]binary -diff -merge -text
792
793

EXAMPLE

795       If you have these three gitattributes file:
796
797           (in $GIT_DIR/info/attributes)
798
799           a*      foo !bar -baz
800
801           (in .gitattributes)
802           abc     foo bar baz
803
804           (in t/.gitattributes)
805           ab*     merge=filfre
806           abc     -foo -bar
807           *.c     frotz
808
809
810       the attributes given to path t/abc are computed as follows:
811
812        1. By examining t/.gitattributes (which is in the same directory as
813           the path in question), Git finds that the first line matches.
814           merge attribute is set. It also finds that the second line matches,
815           and attributes foo and bar are unset.
816
817        2. Then it examines .gitattributes (which is in the parent directory),
818           and finds that the first line matches, but t/.gitattributes file
819           already decided how merge, foo and bar attributes should be given
820           to this path, so it leaves foo and bar unset. Attribute baz is set.
821
822        3. Finally it examines $GIT_DIR/info/attributes. This file is used to
823           override the in-tree settings. The first line is a match, and foo
824           is set, bar is reverted to unspecified state, and baz is unset.
825
826       As the result, the attributes assignment to t/abc becomes:
827
828           foo     set to true
829           bar     unspecified
830           baz     set to false
831           merge   set to string value "filfre"
832           frotz   unspecified
833
834

SEE ALSO

836       git-check-attr(1).
837

GIT

839       Part of the git(1) suite
840
841
842
843Git 1.8.3.1                       11/19/2018                  GITATTRIBUTES(5)
Impressum