Autogenerated HTML docs for v1.7.5-52-ge839f
[git/jnareb-git.git] / gitattributes.html
blob173d7da868ea8311ffe3570b30593ef271bb2114
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>gitattributes(5)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 gitattributes(5) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>gitattributes -
411 defining attributes per path
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="paragraph"><p>$GIT_DIR/info/attributes, .gitattributes</p></div>
418 </div>
419 <h2 id="_description">DESCRIPTION</h2>
420 <div class="sectionbody">
421 <div class="paragraph"><p>A <tt>gitattributes</tt> file is a simple text file that gives
422 <tt>attributes</tt> to pathnames.</p></div>
423 <div class="paragraph"><p>Each line in <tt>gitattributes</tt> file is of form:</p></div>
424 <div class="literalblock">
425 <div class="content">
426 <pre><tt>pattern attr1 attr2 ...</tt></pre>
427 </div></div>
428 <div class="paragraph"><p>That is, a pattern followed by an attributes list,
429 separated by whitespaces. When the pattern matches the
430 path in question, the attributes listed on the line are given to
431 the path.</p></div>
432 <div class="paragraph"><p>Each attribute can be in one of these states for a given path:</p></div>
433 <div class="dlist"><dl>
434 <dt class="hdlist1">
436 </dt>
437 <dd>
439 The path has the attribute with special value "true";
440 this is specified by listing only the name of the
441 attribute in the attribute list.
442 </p>
443 </dd>
444 <dt class="hdlist1">
445 Unset
446 </dt>
447 <dd>
449 The path has the attribute with special value "false";
450 this is specified by listing the name of the attribute
451 prefixed with a dash <tt>-</tt> in the attribute list.
452 </p>
453 </dd>
454 <dt class="hdlist1">
455 Set to a value
456 </dt>
457 <dd>
459 The path has the attribute with specified string value;
460 this is specified by listing the name of the attribute
461 followed by an equal sign <tt>=</tt> and its value in the
462 attribute list.
463 </p>
464 </dd>
465 <dt class="hdlist1">
466 Unspecified
467 </dt>
468 <dd>
470 No pattern matches the path, and nothing says if
471 the path has or does not have the attribute, the
472 attribute for the path is said to be Unspecified.
473 </p>
474 </dd>
475 </dl></div>
476 <div class="paragraph"><p>When more than one pattern matches the path, a later line
477 overrides an earlier line. This overriding is done per
478 attribute. The rules how the pattern matches paths are the
479 same as in <tt>.gitignore</tt> files; see <a href="gitignore.html">gitignore(5)</a>.</p></div>
480 <div class="paragraph"><p>When deciding what attributes are assigned to a path, git
481 consults <tt>$GIT_DIR/info/attributes</tt> file (which has the highest
482 precedence), <tt>.gitattributes</tt> file in the same directory as the
483 path in question, and its parent directories up to the toplevel of the
484 work tree (the further the directory that contains <tt>.gitattributes</tt>
485 is from the path in question, the lower its precedence). Finally
486 global and system-wide files are considered (they have the lowest
487 precedence).</p></div>
488 <div class="paragraph"><p>If you wish to affect only a single repository (i.e., to assign
489 attributes to files that are particular to
490 one user&#8217;s workflow for that repository), then
491 attributes should be placed in the <tt>$GIT_DIR/info/attributes</tt> file.
492 Attributes which should be version-controlled and distributed to other
493 repositories (i.e., attributes of interest to all users) should go into
494 <tt>.gitattributes</tt> files. Attributes that should affect all repositories
495 for a single user should be placed in a file specified by the
496 <tt>core.attributesfile</tt> configuration option (see <a href="git-config.html">git-config(1)</a>).
497 Attributes for all users on a system should be placed in the
498 <tt>$(prefix)/etc/gitattributes</tt> file.</p></div>
499 <div class="paragraph"><p>Sometimes you would need to override an setting of an attribute
500 for a path to <tt>unspecified</tt> state. This can be done by listing
501 the name of the attribute prefixed with an exclamation point <tt>!</tt>.</p></div>
502 </div>
503 <h2 id="_effects">EFFECTS</h2>
504 <div class="sectionbody">
505 <div class="paragraph"><p>Certain operations by git can be influenced by assigning
506 particular attributes to a path. Currently, the following
507 operations are attributes-aware.</p></div>
508 <h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3><div style="clear:left"></div>
509 <div class="paragraph"><p>These attributes affect how the contents stored in the
510 repository are copied to the working tree files when commands
511 such as <em>git checkout</em> and <em>git merge</em> run. They also affect how
512 git stores the contents you prepare in the working tree in the
513 repository upon <em>git add</em> and <em>git commit</em>.</p></div>
514 <h4 id="_tt_text_tt"><tt>text</tt></h4>
515 <div class="paragraph"><p>This attribute enables and controls end-of-line normalization. When a
516 text file is normalized, its line endings are converted to LF in the
517 repository. To control what line ending style is used in the working
518 directory, use the <tt>eol</tt> attribute for a single file and the
519 <tt>core.eol</tt> configuration variable for all text files.</p></div>
520 <div class="dlist"><dl>
521 <dt class="hdlist1">
523 </dt>
524 <dd>
526 Setting the <tt>text</tt> attribute on a path enables end-of-line
527 normalization and marks the path as a text file. End-of-line
528 conversion takes place without guessing the content type.
529 </p>
530 </dd>
531 <dt class="hdlist1">
532 Unset
533 </dt>
534 <dd>
536 Unsetting the <tt>text</tt> attribute on a path tells git not to
537 attempt any end-of-line conversion upon checkin or checkout.
538 </p>
539 </dd>
540 <dt class="hdlist1">
541 Set to string value "auto"
542 </dt>
543 <dd>
545 When <tt>text</tt> is set to "auto", the path is marked for automatic
546 end-of-line normalization. If git decides that the content is
547 text, its line endings are normalized to LF on checkin.
548 </p>
549 </dd>
550 <dt class="hdlist1">
551 Unspecified
552 </dt>
553 <dd>
555 If the <tt>text</tt> attribute is unspecified, git uses the
556 <tt>core.autocrlf</tt> configuration variable to determine if the
557 file should be converted.
558 </p>
559 </dd>
560 </dl></div>
561 <div class="paragraph"><p>Any other value causes git to act as if <tt>text</tt> has been left
562 unspecified.</p></div>
563 <h4 id="_tt_eol_tt"><tt>eol</tt></h4>
564 <div class="paragraph"><p>This attribute sets a specific line-ending style to be used in the
565 working directory. It enables end-of-line normalization without any
566 content checks, effectively setting the <tt>text</tt> attribute.</p></div>
567 <div class="dlist"><dl>
568 <dt class="hdlist1">
569 Set to string value "crlf"
570 </dt>
571 <dd>
573 This setting forces git to normalize line endings for this
574 file on checkin and convert them to CRLF when the file is
575 checked out.
576 </p>
577 </dd>
578 <dt class="hdlist1">
579 Set to string value "lf"
580 </dt>
581 <dd>
583 This setting forces git to normalize line endings to LF on
584 checkin and prevents conversion to CRLF when the file is
585 checked out.
586 </p>
587 </dd>
588 </dl></div>
589 <h4 id="_backwards_compatibility_with_tt_crlf_tt_attribute">Backwards compatibility with <tt>crlf</tt> attribute</h4>
590 <div class="paragraph"><p>For backwards compatibility, the <tt>crlf</tt> attribute is interpreted as
591 follows:</p></div>
592 <div class="listingblock">
593 <div class="content">
594 <pre><tt>crlf text
595 -crlf -text
596 crlf=input eol=lf</tt></pre>
597 </div></div>
598 <h4 id="_end_of_line_conversion">End-of-line conversion</h4>
599 <div class="paragraph"><p>While git normally leaves file contents alone, it can be configured to
600 normalize line endings to LF in the repository and, optionally, to
601 convert them to CRLF when files are checked out.</p></div>
602 <div class="paragraph"><p>Here is an example that will make git normalize .txt, .vcproj and .sh
603 files, ensure that .vcproj files have CRLF and .sh files have LF in
604 the working directory, and prevent .jpg files from being normalized
605 regardless of their content.</p></div>
606 <div class="listingblock">
607 <div class="content">
608 <pre><tt>*.txt text
609 *.vcproj eol=crlf
610 *.sh eol=lf
611 *.jpg -text</tt></pre>
612 </div></div>
613 <div class="paragraph"><p>Other source code management systems normalize all text files in their
614 repositories, and there are two ways to enable similar automatic
615 normalization in git.</p></div>
616 <div class="paragraph"><p>If you simply want to have CRLF line endings in your working directory
617 regardless of the repository you are working with, you can set the
618 config variable "core.autocrlf" without changing any attributes.</p></div>
619 <div class="listingblock">
620 <div class="content">
621 <pre><tt>[core]
622 autocrlf = true</tt></pre>
623 </div></div>
624 <div class="paragraph"><p>This does not force normalization of all text files, but does ensure
625 that text files that you introduce to the repository have their line
626 endings normalized to LF when they are added, and that files that are
627 already normalized in the repository stay normalized.</p></div>
628 <div class="paragraph"><p>If you want to interoperate with a source code management system that
629 enforces end-of-line normalization, or you simply want all text files
630 in your repository to be normalized, you should instead set the <tt>text</tt>
631 attribute to "auto" for <em>all</em> files.</p></div>
632 <div class="listingblock">
633 <div class="content">
634 <pre><tt>* text=auto</tt></pre>
635 </div></div>
636 <div class="paragraph"><p>This ensures that all files that git considers to be text will have
637 normalized (LF) line endings in the repository. The <tt>core.eol</tt>
638 configuration variable controls which line endings git will use for
639 normalized files in your working directory; the default is to use the
640 native line ending for your platform, or CRLF if <tt>core.autocrlf</tt> is
641 set.</p></div>
642 <div class="admonitionblock">
643 <table><tr>
644 <td class="icon">
645 <div class="title">Note</div>
646 </td>
647 <td class="content">When <tt>text=auto</tt> normalization is enabled in an existing
648 repository, any text files containing CRLFs should be normalized. If
649 they are not they will be normalized the next time someone tries to
650 change them, causing unfortunate misattribution. From a clean working
651 directory:</td>
652 </tr></table>
653 </div>
654 <div class="listingblock">
655 <div class="content">
656 <pre><tt>$ echo "* text=auto" &gt;&gt;.gitattributes
657 $ rm .git/index # Remove the index to force git to
658 $ git reset # re-scan the working directory
659 $ git status # Show files that will be normalized
660 $ git add -u
661 $ git add .gitattributes
662 $ git commit -m "Introduce end-of-line normalization"</tt></pre>
663 </div></div>
664 <div class="paragraph"><p>If any files that should not be normalized show up in <em>git status</em>,
665 unset their <tt>text</tt> attribute before running <em>git add -u</em>.</p></div>
666 <div class="listingblock">
667 <div class="content">
668 <pre><tt>manual.pdf -text</tt></pre>
669 </div></div>
670 <div class="paragraph"><p>Conversely, text files that git does not detect can have normalization
671 enabled manually.</p></div>
672 <div class="listingblock">
673 <div class="content">
674 <pre><tt>weirdchars.txt text</tt></pre>
675 </div></div>
676 <div class="paragraph"><p>If <tt>core.safecrlf</tt> is set to "true" or "warn", git verifies if
677 the conversion is reversible for the current setting of
678 <tt>core.autocrlf</tt>. For "true", git rejects irreversible
679 conversions; for "warn", git only prints a warning but accepts
680 an irreversible conversion. The safety triggers to prevent such
681 a conversion done to the files in the work tree, but there are a
682 few exceptions. Even though&#8230;</p></div>
683 <div class="ulist"><ul>
684 <li>
686 <em>git add</em> itself does not touch the files in the work tree, the
687 next checkout would, so the safety triggers;
688 </p>
689 </li>
690 <li>
692 <em>git apply</em> to update a text file with a patch does touch the files
693 in the work tree, but the operation is about text files and CRLF
694 conversion is about fixing the line ending inconsistencies, so the
695 safety does not trigger;
696 </p>
697 </li>
698 <li>
700 <em>git diff</em> itself does not touch the files in the work tree, it is
701 often run to inspect the changes you intend to next <em>git add</em>. To
702 catch potential problems early, safety triggers.
703 </p>
704 </li>
705 </ul></div>
706 <h4 id="_tt_ident_tt"><tt>ident</tt></h4>
707 <div class="paragraph"><p>When the attribute <tt>ident</tt> is set for a path, git replaces
708 <tt>$Id$</tt> in the blob object with <tt>$Id:</tt>, followed by the
709 40-character hexadecimal blob object name, followed by a dollar
710 sign <tt>$</tt> upon checkout. Any byte sequence that begins with
711 <tt>$Id:</tt> and ends with <tt>$</tt> in the worktree file is replaced
712 with <tt>$Id$</tt> upon check-in.</p></div>
713 <h4 id="_tt_filter_tt"><tt>filter</tt></h4>
714 <div class="paragraph"><p>A <tt>filter</tt> attribute can be set to a string value that names a
715 filter driver specified in the configuration.</p></div>
716 <div class="paragraph"><p>A filter driver consists of a <tt>clean</tt> command and a <tt>smudge</tt>
717 command, either of which can be left unspecified. Upon
718 checkout, when the <tt>smudge</tt> command is specified, the command is
719 fed the blob object from its standard input, and its standard
720 output is used to update the worktree file. Similarly, the
721 <tt>clean</tt> command is used to convert the contents of worktree file
722 upon checkin.</p></div>
723 <div class="paragraph"><p>A missing filter driver definition in the config is not an error
724 but makes the filter a no-op passthru.</p></div>
725 <div class="paragraph"><p>The content filtering is done to massage the content into a
726 shape that is more convenient for the platform, filesystem, and
727 the user to use. The key phrase here is "more convenient" and not
728 "turning something unusable into usable". In other words, the
729 intent is that if someone unsets the filter driver definition,
730 or does not have the appropriate filter program, the project
731 should still be usable.</p></div>
732 <div class="paragraph"><p>For example, in .gitattributes, you would assign the <tt>filter</tt>
733 attribute for paths.</p></div>
734 <div class="listingblock">
735 <div class="content">
736 <pre><tt>*.c filter=indent</tt></pre>
737 </div></div>
738 <div class="paragraph"><p>Then you would define a "filter.indent.clean" and "filter.indent.smudge"
739 configuration in your .git/config to specify a pair of commands to
740 modify the contents of C programs when the source files are checked
741 in ("clean" is run) and checked out (no change is made because the
742 command is "cat").</p></div>
743 <div class="listingblock">
744 <div class="content">
745 <pre><tt>[filter "indent"]
746 clean = indent
747 smudge = cat</tt></pre>
748 </div></div>
749 <div class="paragraph"><p>For best results, <tt>clean</tt> should not alter its output further if it is
750 run twice ("clean&#8594;clean" should be equivalent to "clean"), and
751 multiple <tt>smudge</tt> commands should not alter <tt>clean</tt>'s output
752 ("smudge&#8594;smudge&#8594;clean" should be equivalent to "clean"). See the
753 section on merging below.</p></div>
754 <div class="paragraph"><p>The "indent" filter is well-behaved in this regard: it will not modify
755 input that is already correctly indented. In this case, the lack of a
756 smudge filter means that the clean filter <em>must</em> accept its own output
757 without modifying it.</p></div>
758 <div class="paragraph"><p>Sequence "%f" on the filter command line is replaced with the name of
759 the file the filter is working on. A filter might use this in keyword
760 substitution. For example:</p></div>
761 <div class="listingblock">
762 <div class="content">
763 <pre><tt>[filter "p4"]
764 clean = git-p4-filter --clean %f
765 smudge = git-p4-filter --smudge %f</tt></pre>
766 </div></div>
767 <h4 id="_interaction_between_checkin_checkout_attributes">Interaction between checkin/checkout attributes</h4>
768 <div class="paragraph"><p>In the check-in codepath, the worktree file is first converted
769 with <tt>filter</tt> driver (if specified and corresponding driver
770 defined), then the result is processed with <tt>ident</tt> (if
771 specified), and then finally with <tt>text</tt> (again, if specified
772 and applicable).</p></div>
773 <div class="paragraph"><p>In the check-out codepath, the blob content is first converted
774 with <tt>text</tt>, and then <tt>ident</tt> and fed to <tt>filter</tt>.</p></div>
775 <h4 id="_merging_branches_with_differing_checkin_checkout_attributes">Merging branches with differing checkin/checkout attributes</h4>
776 <div class="paragraph"><p>If you have added attributes to a file that cause the canonical
777 repository format for that file to change, such as adding a
778 clean/smudge filter or text/eol/ident attributes, merging anything
779 where the attribute is not in place would normally cause merge
780 conflicts.</p></div>
781 <div class="paragraph"><p>To prevent these unnecessary merge conflicts, git can be told to run a
782 virtual check-out and check-in of all three stages of a file when
783 resolving a three-way merge by setting the <tt>merge.renormalize</tt>
784 configuration variable. This prevents changes caused by check-in
785 conversion from causing spurious merge conflicts when a converted file
786 is merged with an unconverted file.</p></div>
787 <div class="paragraph"><p>As long as a "smudge&#8594;clean" results in the same output as a "clean"
788 even on files that are already smudged, this strategy will
789 automatically resolve all filter-related conflicts. Filters that do
790 not act in this way may cause additional merge conflicts that must be
791 resolved manually.</p></div>
792 <h3 id="_generating_diff_text">Generating diff text</h3><div style="clear:left"></div>
793 <h4 id="_tt_diff_tt"><tt>diff</tt></h4>
794 <div class="paragraph"><p>The attribute <tt>diff</tt> affects how <em>git</em> generates diffs for particular
795 files. It can tell git whether to generate a textual patch for the path
796 or to treat the path as a binary file. It can also affect what line is
797 shown on the hunk header <tt>@@ -k,l +n,m @@</tt> line, tell git to use an
798 external command to generate the diff, or ask git to convert binary
799 files to a text format before generating the diff.</p></div>
800 <div class="dlist"><dl>
801 <dt class="hdlist1">
803 </dt>
804 <dd>
806 A path to which the <tt>diff</tt> attribute is set is treated
807 as text, even when they contain byte values that
808 normally never appear in text files, such as NUL.
809 </p>
810 </dd>
811 <dt class="hdlist1">
812 Unset
813 </dt>
814 <dd>
816 A path to which the <tt>diff</tt> attribute is unset will
817 generate <tt>Binary files differ</tt> (or a binary patch, if
818 binary patches are enabled).
819 </p>
820 </dd>
821 <dt class="hdlist1">
822 Unspecified
823 </dt>
824 <dd>
826 A path to which the <tt>diff</tt> attribute is unspecified
827 first gets its contents inspected, and if it looks like
828 text, it is treated as text. Otherwise it would
829 generate <tt>Binary files differ</tt>.
830 </p>
831 </dd>
832 <dt class="hdlist1">
833 String
834 </dt>
835 <dd>
837 Diff is shown using the specified diff driver. Each driver may
838 specify one or more options, as described in the following
839 section. The options for the diff driver "foo" are defined
840 by the configuration variables in the "diff.foo" section of the
841 git config file.
842 </p>
843 </dd>
844 </dl></div>
845 <h4 id="_defining_an_external_diff_driver">Defining an external diff driver</h4>
846 <div class="paragraph"><p>The definition of a diff driver is done in <tt>gitconfig</tt>, not
847 <tt>gitattributes</tt> file, so strictly speaking this manual page is a
848 wrong place to talk about it. However&#8230;</p></div>
849 <div class="paragraph"><p>To define an external diff driver <tt>jcdiff</tt>, add a section to your
850 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
851 <div class="listingblock">
852 <div class="content">
853 <pre><tt>[diff "jcdiff"]
854 command = j-c-diff</tt></pre>
855 </div></div>
856 <div class="paragraph"><p>When git needs to show you a diff for the path with <tt>diff</tt>
857 attribute set to <tt>jcdiff</tt>, it calls the command you specified
858 with the above configuration, i.e. <tt>j-c-diff</tt>, with 7
859 parameters, just like <tt>GIT_EXTERNAL_DIFF</tt> program is called.
860 See <a href="git.html">git(1)</a> for details.</p></div>
861 <h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4>
862 <div class="paragraph"><p>Each group of changes (called a "hunk") in the textual diff output
863 is prefixed with a line of the form:</p></div>
864 <div class="literalblock">
865 <div class="content">
866 <pre><tt>@@ -k,l +n,m @@ TEXT</tt></pre>
867 </div></div>
868 <div class="paragraph"><p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line
869 that begins with an alphabet, an underscore or a dollar sign; this
870 matches what GNU <em>diff -p</em> output uses. This default selection however
871 is not suited for some contents, and you can use a customized pattern
872 to make a selection.</p></div>
873 <div class="paragraph"><p>First, in .gitattributes, you would assign the <tt>diff</tt> attribute
874 for paths.</p></div>
875 <div class="listingblock">
876 <div class="content">
877 <pre><tt>*.tex diff=tex</tt></pre>
878 </div></div>
879 <div class="paragraph"><p>Then, you would define a "diff.tex.xfuncname" configuration to
880 specify a regular expression that matches a line that you would
881 want to appear as the hunk header "TEXT". Add a section to your
882 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
883 <div class="listingblock">
884 <div class="content">
885 <pre><tt>[diff "tex"]
886 xfuncname = "^(\\\\(sub)*section\\{.*)$"</tt></pre>
887 </div></div>
888 <div class="paragraph"><p>Note. A single level of backslashes are eaten by the
889 configuration file parser, so you would need to double the
890 backslashes; the pattern above picks a line that begins with a
891 backslash, and zero or more occurrences of <tt>sub</tt> followed by
892 <tt>section</tt> followed by open brace, to the end of line.</p></div>
893 <div class="paragraph"><p>There are a few built-in patterns to make this easier, and <tt>tex</tt>
894 is one of them, so you do not have to write the above in your
895 configuration file (you still need to enable this with the
896 attribute mechanism, via <tt>.gitattributes</tt>). The following built in
897 patterns are available:</p></div>
898 <div class="ulist"><ul>
899 <li>
901 <tt>bibtex</tt> suitable for files with BibTeX coded references.
902 </p>
903 </li>
904 <li>
906 <tt>cpp</tt> suitable for source code in the C and C++ languages.
907 </p>
908 </li>
909 <li>
911 <tt>csharp</tt> suitable for source code in the C# language.
912 </p>
913 </li>
914 <li>
916 <tt>fortran</tt> suitable for source code in the Fortran language.
917 </p>
918 </li>
919 <li>
921 <tt>html</tt> suitable for HTML/XHTML documents.
922 </p>
923 </li>
924 <li>
926 <tt>java</tt> suitable for source code in the Java language.
927 </p>
928 </li>
929 <li>
931 <tt>objc</tt> suitable for source code in the Objective-C language.
932 </p>
933 </li>
934 <li>
936 <tt>pascal</tt> suitable for source code in the Pascal/Delphi language.
937 </p>
938 </li>
939 <li>
941 <tt>perl</tt> suitable for source code in the Perl language.
942 </p>
943 </li>
944 <li>
946 <tt>php</tt> suitable for source code in the PHP language.
947 </p>
948 </li>
949 <li>
951 <tt>python</tt> suitable for source code in the Python language.
952 </p>
953 </li>
954 <li>
956 <tt>ruby</tt> suitable for source code in the Ruby language.
957 </p>
958 </li>
959 <li>
961 <tt>tex</tt> suitable for source code for LaTeX documents.
962 </p>
963 </li>
964 </ul></div>
965 <h4 id="_customizing_word_diff">Customizing word diff</h4>
966 <div class="paragraph"><p>You can customize the rules that <tt>git diff --word-diff</tt> uses to
967 split words in a line, by specifying an appropriate regular expression
968 in the "diff.*.wordRegex" configuration variable. For example, in TeX
969 a backslash followed by a sequence of letters forms a command, but
970 several such commands can be run together without intervening
971 whitespace. To separate them, use a regular expression in your
972 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
973 <div class="listingblock">
974 <div class="content">
975 <pre><tt>[diff "tex"]
976 wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</tt></pre>
977 </div></div>
978 <div class="paragraph"><p>A built-in pattern is provided for all languages listed in the
979 previous section.</p></div>
980 <h4 id="_performing_text_diffs_of_binary_files">Performing text diffs of binary files</h4>
981 <div class="paragraph"><p>Sometimes it is desirable to see the diff of a text-converted
982 version of some binary files. For example, a word processor
983 document can be converted to an ASCII text representation, and
984 the diff of the text shown. Even though this conversion loses
985 some information, the resulting diff is useful for human
986 viewing (but cannot be applied directly).</p></div>
987 <div class="paragraph"><p>The <tt>textconv</tt> config option is used to define a program for
988 performing such a conversion. The program should take a single
989 argument, the name of a file to convert, and produce the
990 resulting text on stdout.</p></div>
991 <div class="paragraph"><p>For example, to show the diff of the exif information of a
992 file instead of the binary information (assuming you have the
993 exif tool installed), add the following section to your
994 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file):</p></div>
995 <div class="listingblock">
996 <div class="content">
997 <pre><tt>[diff "jpg"]
998 textconv = exif</tt></pre>
999 </div></div>
1000 <div class="admonitionblock">
1001 <table><tr>
1002 <td class="icon">
1003 <div class="title">Note</div>
1004 </td>
1005 <td class="content">The text conversion is generally a one-way conversion;
1006 in this example, we lose the actual image contents and focus
1007 just on the text data. This means that diffs generated by
1008 textconv are <em>not</em> suitable for applying. For this reason,
1009 only <tt>git diff</tt> and the <tt>git log</tt> family of commands (i.e.,
1010 log, whatchanged, show) will perform text conversion. <tt>git
1011 format-patch</tt> will never generate this output. If you want to
1012 send somebody a text-converted diff of a binary file (e.g.,
1013 because it quickly conveys the changes you have made), you
1014 should generate it separately and send it as a comment <em>in
1015 addition to</em> the usual binary diff that you might send.</td>
1016 </tr></table>
1017 </div>
1018 <div class="paragraph"><p>Because text conversion can be slow, especially when doing a
1019 large number of them with <tt>git log -p</tt>, git provides a mechanism
1020 to cache the output and use it in future diffs. To enable
1021 caching, set the "cachetextconv" variable in your diff driver&#8217;s
1022 config. For example:</p></div>
1023 <div class="listingblock">
1024 <div class="content">
1025 <pre><tt>[diff "jpg"]
1026 textconv = exif
1027 cachetextconv = true</tt></pre>
1028 </div></div>
1029 <div class="paragraph"><p>This will cache the result of running "exif" on each blob
1030 indefinitely. If you change the textconv config variable for a
1031 diff driver, git will automatically invalidate the cache entries
1032 and re-run the textconv filter. If you want to invalidate the
1033 cache manually (e.g., because your version of "exif" was updated
1034 and now produces better output), you can remove the cache
1035 manually with <tt>git update-ref -d refs/notes/textconv/jpg</tt> (where
1036 "jpg" is the name of the diff driver, as in the example above).</p></div>
1037 <h4 id="_marking_files_as_binary">Marking files as binary</h4>
1038 <div class="paragraph"><p>Git usually guesses correctly whether a blob contains text or binary
1039 data by examining the beginning of the contents. However, sometimes you
1040 may want to override its decision, either because a blob contains binary
1041 data later in the file, or because the content, while technically
1042 composed of text characters, is opaque to a human reader. For example,
1043 many postscript files contain only ascii characters, but produce noisy
1044 and meaningless diffs.</p></div>
1045 <div class="paragraph"><p>The simplest way to mark a file as binary is to unset the diff
1046 attribute in the <tt>.gitattributes</tt> file:</p></div>
1047 <div class="listingblock">
1048 <div class="content">
1049 <pre><tt>*.ps -diff</tt></pre>
1050 </div></div>
1051 <div class="paragraph"><p>This will cause git to generate <tt>Binary files differ</tt> (or a binary
1052 patch, if binary patches are enabled) instead of a regular diff.</p></div>
1053 <div class="paragraph"><p>However, one may also want to specify other diff driver attributes. For
1054 example, you might want to use <tt>textconv</tt> to convert postscript files to
1055 an ascii representation for human viewing, but otherwise treat them as
1056 binary files. You cannot specify both <tt>-diff</tt> and <tt>diff=ps</tt> attributes.
1057 The solution is to use the <tt>diff.*.binary</tt> config option:</p></div>
1058 <div class="listingblock">
1059 <div class="content">
1060 <pre><tt>[diff "ps"]
1061 textconv = ps2ascii
1062 binary = true</tt></pre>
1063 </div></div>
1064 <h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3><div style="clear:left"></div>
1065 <h4 id="_tt_merge_tt"><tt>merge</tt></h4>
1066 <div class="paragraph"><p>The attribute <tt>merge</tt> affects how three versions of a file are
1067 merged when a file-level merge is necessary during <tt>git merge</tt>,
1068 and other commands such as <tt>git revert</tt> and <tt>git cherry-pick</tt>.</p></div>
1069 <div class="dlist"><dl>
1070 <dt class="hdlist1">
1072 </dt>
1073 <dd>
1075 Built-in 3-way merge driver is used to merge the
1076 contents in a way similar to <em>merge</em> command of <tt>RCS</tt>
1077 suite. This is suitable for ordinary text files.
1078 </p>
1079 </dd>
1080 <dt class="hdlist1">
1081 Unset
1082 </dt>
1083 <dd>
1085 Take the version from the current branch as the
1086 tentative merge result, and declare that the merge has
1087 conflicts. This is suitable for binary files that do
1088 not have a well-defined merge semantics.
1089 </p>
1090 </dd>
1091 <dt class="hdlist1">
1092 Unspecified
1093 </dt>
1094 <dd>
1096 By default, this uses the same built-in 3-way merge
1097 driver as is the case when the <tt>merge</tt> attribute is set.
1098 However, the <tt>merge.default</tt> configuration variable can name
1099 different merge driver to be used with paths for which the
1100 <tt>merge</tt> attribute is unspecified.
1101 </p>
1102 </dd>
1103 <dt class="hdlist1">
1104 String
1105 </dt>
1106 <dd>
1108 3-way merge is performed using the specified custom
1109 merge driver. The built-in 3-way merge driver can be
1110 explicitly specified by asking for "text" driver; the
1111 built-in "take the current branch" driver can be
1112 requested with "binary".
1113 </p>
1114 </dd>
1115 </dl></div>
1116 <h4 id="_built_in_merge_drivers">Built-in merge drivers</h4>
1117 <div class="paragraph"><p>There are a few built-in low-level merge drivers defined that
1118 can be asked for via the <tt>merge</tt> attribute.</p></div>
1119 <div class="dlist"><dl>
1120 <dt class="hdlist1">
1121 text
1122 </dt>
1123 <dd>
1125 Usual 3-way file level merge for text files. Conflicted
1126 regions are marked with conflict markers <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt>,
1127 <tt>=======</tt> and <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt>. The version from your branch
1128 appears before the <tt>=======</tt> marker, and the version
1129 from the merged branch appears after the <tt>=======</tt>
1130 marker.
1131 </p>
1132 </dd>
1133 <dt class="hdlist1">
1134 binary
1135 </dt>
1136 <dd>
1138 Keep the version from your branch in the work tree, but
1139 leave the path in the conflicted state for the user to
1140 sort out.
1141 </p>
1142 </dd>
1143 <dt class="hdlist1">
1144 union
1145 </dt>
1146 <dd>
1148 Run 3-way file level merge for text files, but take
1149 lines from both versions, instead of leaving conflict
1150 markers. This tends to leave the added lines in the
1151 resulting file in random order and the user should
1152 verify the result. Do not use this if you do not
1153 understand the implications.
1154 </p>
1155 </dd>
1156 </dl></div>
1157 <h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4>
1158 <div class="paragraph"><p>The definition of a merge driver is done in the <tt>.git/config</tt>
1159 file, not in the <tt>gitattributes</tt> file, so strictly speaking this
1160 manual page is a wrong place to talk about it. However&#8230;</p></div>
1161 <div class="paragraph"><p>To define a custom merge driver <tt>filfre</tt>, add a section to your
1162 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
1163 <div class="listingblock">
1164 <div class="content">
1165 <pre><tt>[merge "filfre"]
1166 name = feel-free merge driver
1167 driver = filfre %O %A %B
1168 recursive = binary</tt></pre>
1169 </div></div>
1170 <div class="paragraph"><p>The <tt>merge.*.name</tt> variable gives the driver a human-readable
1171 name.</p></div>
1172 <div class="paragraph"><p>The &#8216;merge.*.driver` variable&#8217;s value is used to construct a
1173 command to run to merge ancestor&#8217;s version (<tt>%O</tt>), current
1174 version (<tt>%A</tt>) and the other branches&#8217; version (<tt>%B</tt>). These
1175 three tokens are replaced with the names of temporary files that
1176 hold the contents of these versions when the command line is
1177 built. Additionally, %L will be replaced with the conflict marker
1178 size (see below).</p></div>
1179 <div class="paragraph"><p>The merge driver is expected to leave the result of the merge in
1180 the file named with <tt>%A</tt> by overwriting it, and exit with zero
1181 status if it managed to merge them cleanly, or non-zero if there
1182 were conflicts.</p></div>
1183 <div class="paragraph"><p>The <tt>merge.*.recursive</tt> variable specifies what other merge
1184 driver to use when the merge driver is called for an internal
1185 merge between common ancestors, when there are more than one.
1186 When left unspecified, the driver itself is used for both
1187 internal merge and the final merge.</p></div>
1188 <h4 id="_tt_conflict_marker_size_tt"><tt>conflict-marker-size</tt></h4>
1189 <div class="paragraph"><p>This attribute controls the length of conflict markers left in
1190 the work tree file during a conflicted merge. Only setting to
1191 the value to a positive integer has any meaningful effect.</p></div>
1192 <div class="paragraph"><p>For example, this line in <tt>.gitattributes</tt> can be used to tell the merge
1193 machinery to leave much longer (instead of the usual 7-character-long)
1194 conflict markers when merging the file <tt>Documentation/git-merge.txt</tt>
1195 results in a conflict.</p></div>
1196 <div class="listingblock">
1197 <div class="content">
1198 <pre><tt>Documentation/git-merge.txt conflict-marker-size=32</tt></pre>
1199 </div></div>
1200 <h3 id="_checking_whitespace_errors">Checking whitespace errors</h3><div style="clear:left"></div>
1201 <h4 id="_tt_whitespace_tt"><tt>whitespace</tt></h4>
1202 <div class="paragraph"><p>The <tt>core.whitespace</tt> configuration variable allows you to define what
1203 <em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in
1204 the project (See <a href="git-config.html">git-config(1)</a>). This attribute gives you finer
1205 control per path.</p></div>
1206 <div class="dlist"><dl>
1207 <dt class="hdlist1">
1209 </dt>
1210 <dd>
1212 Notice all types of potential whitespace errors known to git.
1213 The tab width is taken from the value of the <tt>core.whitespace</tt>
1214 configuration variable.
1215 </p>
1216 </dd>
1217 <dt class="hdlist1">
1218 Unset
1219 </dt>
1220 <dd>
1222 Do not notice anything as error.
1223 </p>
1224 </dd>
1225 <dt class="hdlist1">
1226 Unspecified
1227 </dt>
1228 <dd>
1230 Use the value of the <tt>core.whitespace</tt> configuration variable to
1231 decide what to notice as error.
1232 </p>
1233 </dd>
1234 <dt class="hdlist1">
1235 String
1236 </dt>
1237 <dd>
1239 Specify a comma separate list of common whitespace problems to
1240 notice in the same format as the <tt>core.whitespace</tt> configuration
1241 variable.
1242 </p>
1243 </dd>
1244 </dl></div>
1245 <h3 id="_creating_an_archive">Creating an archive</h3><div style="clear:left"></div>
1246 <h4 id="_tt_export_ignore_tt"><tt>export-ignore</tt></h4>
1247 <div class="paragraph"><p>Files and directories with the attribute <tt>export-ignore</tt> won&#8217;t be added to
1248 archive files.</p></div>
1249 <h4 id="_tt_export_subst_tt"><tt>export-subst</tt></h4>
1250 <div class="paragraph"><p>If the attribute <tt>export-subst</tt> is set for a file then git will expand
1251 several placeholders when adding this file to an archive. The
1252 expansion depends on the availability of a commit ID, i.e., if
1253 <a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a
1254 tag then no replacement will be done. The placeholders are the same
1255 as those for the option <tt>--pretty=format:</tt> of <a href="git-log.html">git-log(1)</a>,
1256 except that they need to be wrapped like this: <tt>$Format:PLACEHOLDERS$</tt>
1257 in the file. E.g. the string <tt>$Format:%H$</tt> will be replaced by the
1258 commit hash.</p></div>
1259 <h3 id="_packing_objects">Packing objects</h3><div style="clear:left"></div>
1260 <h4 id="_tt_delta_tt"><tt>delta</tt></h4>
1261 <div class="paragraph"><p>Delta compression will not be attempted for blobs for paths with the
1262 attribute <tt>delta</tt> set to false.</p></div>
1263 <h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3><div style="clear:left"></div>
1264 <h4 id="_tt_encoding_tt"><tt>encoding</tt></h4>
1265 <div class="paragraph"><p>The value of this attribute specifies the character encoding that should
1266 be used by GUI tools (e.g. <a href="gitk.html">gitk(1)</a> and <a href="git-gui.html">git-gui(1)</a>) to
1267 display the contents of the relevant file. Note that due to performance
1268 considerations <a href="gitk.html">gitk(1)</a> does not use this attribute unless you
1269 manually enable per-file encodings in its options.</p></div>
1270 <div class="paragraph"><p>If this attribute is not set or has an invalid value, the value of the
1271 <tt>gui.encoding</tt> configuration variable is used instead
1272 (See <a href="git-config.html">git-config(1)</a>).</p></div>
1273 </div>
1274 <h2 id="_using_attribute_macros">USING ATTRIBUTE MACROS</h2>
1275 <div class="sectionbody">
1276 <div class="paragraph"><p>You do not want any end-of-line conversions applied to, nor textual diffs
1277 produced for, any binary file you track. You would need to specify e.g.</p></div>
1278 <div class="listingblock">
1279 <div class="content">
1280 <pre><tt>*.jpg -text -diff</tt></pre>
1281 </div></div>
1282 <div class="paragraph"><p>but that may become cumbersome, when you have many attributes. Using
1283 attribute macros, you can specify groups of attributes set or unset at
1284 the same time. The system knows a built-in attribute macro, <tt>binary</tt>:</p></div>
1285 <div class="listingblock">
1286 <div class="content">
1287 <pre><tt>*.jpg binary</tt></pre>
1288 </div></div>
1289 <div class="paragraph"><p>which is equivalent to the above. Note that the attribute macros can only
1290 be "Set" (see the above example that sets "binary" macro as if it were an
1291 ordinary attribute --- setting it in turn unsets "text" and "diff").</p></div>
1292 </div>
1293 <h2 id="_defining_attribute_macros">DEFINING ATTRIBUTE MACROS</h2>
1294 <div class="sectionbody">
1295 <div class="paragraph"><p>Custom attribute macros can be defined only in the <tt>.gitattributes</tt> file
1296 at the toplevel (i.e. not in any subdirectory). The built-in attribute
1297 macro "binary" is equivalent to:</p></div>
1298 <div class="listingblock">
1299 <div class="content">
1300 <pre><tt>[attr]binary -diff -text</tt></pre>
1301 </div></div>
1302 </div>
1303 <h2 id="_example">EXAMPLE</h2>
1304 <div class="sectionbody">
1305 <div class="paragraph"><p>If you have these three <tt>gitattributes</tt> file:</p></div>
1306 <div class="listingblock">
1307 <div class="content">
1308 <pre><tt>(in $GIT_DIR/info/attributes)
1310 a* foo !bar -baz
1312 (in .gitattributes)
1313 abc foo bar baz
1315 (in t/.gitattributes)
1316 ab* merge=filfre
1317 abc -foo -bar
1318 *.c frotz</tt></pre>
1319 </div></div>
1320 <div class="paragraph"><p>the attributes given to path <tt>t/abc</tt> are computed as follows:</p></div>
1321 <div class="olist arabic"><ol class="arabic">
1322 <li>
1324 By examining <tt>t/.gitattributes</tt> (which is in the same
1325 directory as the path in question), git finds that the first
1326 line matches. <tt>merge</tt> attribute is set. It also finds that
1327 the second line matches, and attributes <tt>foo</tt> and <tt>bar</tt>
1328 are unset.
1329 </p>
1330 </li>
1331 <li>
1333 Then it examines <tt>.gitattributes</tt> (which is in the parent
1334 directory), and finds that the first line matches, but
1335 <tt>t/.gitattributes</tt> file already decided how <tt>merge</tt>, <tt>foo</tt>
1336 and <tt>bar</tt> attributes should be given to this path, so it
1337 leaves <tt>foo</tt> and <tt>bar</tt> unset. Attribute <tt>baz</tt> is set.
1338 </p>
1339 </li>
1340 <li>
1342 Finally it examines <tt>$GIT_DIR/info/attributes</tt>. This file
1343 is used to override the in-tree settings. The first line is
1344 a match, and <tt>foo</tt> is set, <tt>bar</tt> is reverted to unspecified
1345 state, and <tt>baz</tt> is unset.
1346 </p>
1347 </li>
1348 </ol></div>
1349 <div class="paragraph"><p>As the result, the attributes assignment to <tt>t/abc</tt> becomes:</p></div>
1350 <div class="listingblock">
1351 <div class="content">
1352 <pre><tt>foo set to true
1353 bar unspecified
1354 baz set to false
1355 merge set to string value "filfre"
1356 frotz unspecified</tt></pre>
1357 </div></div>
1358 </div>
1359 <h2 id="_git">GIT</h2>
1360 <div class="sectionbody">
1361 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1362 </div>
1363 <div id="footer">
1364 <div id="footer-text">
1365 Last updated 2011-03-19 01:35:18 UTC
1366 </div>
1367 </div>
1368 </body>
1369 </html>