Autogenerated HTML docs for v1.7.7-237-g34c44
[git/jnareb-git.git] / gitattributes.html
blob2ef690bdf37d1c27b5510f5e7ea7603fed5413f5
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.5.2" />
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.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 gitattributes(5) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>gitattributes -
578 defining attributes per path
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="paragraph"><p>$GIT_DIR/info/attributes, .gitattributes</p></div>
586 </div>
587 <h2 id="_description">DESCRIPTION</h2>
588 <div class="sectionbody">
589 <div class="paragraph"><p>A <tt>gitattributes</tt> file is a simple text file that gives
590 <tt>attributes</tt> to pathnames.</p></div>
591 <div class="paragraph"><p>Each line in <tt>gitattributes</tt> file is of form:</p></div>
592 <div class="literalblock">
593 <div class="content">
594 <pre><tt>pattern attr1 attr2 ...</tt></pre>
595 </div></div>
596 <div class="paragraph"><p>That is, a pattern followed by an attributes list,
597 separated by whitespaces. When the pattern matches the
598 path in question, the attributes listed on the line are given to
599 the path.</p></div>
600 <div class="paragraph"><p>Each attribute can be in one of these states for a given path:</p></div>
601 <div class="dlist"><dl>
602 <dt class="hdlist1">
604 </dt>
605 <dd>
607 The path has the attribute with special value "true";
608 this is specified by listing only the name of the
609 attribute in the attribute list.
610 </p>
611 </dd>
612 <dt class="hdlist1">
613 Unset
614 </dt>
615 <dd>
617 The path has the attribute with special value "false";
618 this is specified by listing the name of the attribute
619 prefixed with a dash <tt>-</tt> in the attribute list.
620 </p>
621 </dd>
622 <dt class="hdlist1">
623 Set to a value
624 </dt>
625 <dd>
627 The path has the attribute with specified string value;
628 this is specified by listing the name of the attribute
629 followed by an equal sign <tt>=</tt> and its value in the
630 attribute list.
631 </p>
632 </dd>
633 <dt class="hdlist1">
634 Unspecified
635 </dt>
636 <dd>
638 No pattern matches the path, and nothing says if
639 the path has or does not have the attribute, the
640 attribute for the path is said to be Unspecified.
641 </p>
642 </dd>
643 </dl></div>
644 <div class="paragraph"><p>When more than one pattern matches the path, a later line
645 overrides an earlier line. This overriding is done per
646 attribute. The rules how the pattern matches paths are the
647 same as in <tt>.gitignore</tt> files; see <a href="gitignore.html">gitignore(5)</a>.</p></div>
648 <div class="paragraph"><p>When deciding what attributes are assigned to a path, git
649 consults <tt>$GIT_DIR/info/attributes</tt> file (which has the highest
650 precedence), <tt>.gitattributes</tt> file in the same directory as the
651 path in question, and its parent directories up to the toplevel of the
652 work tree (the further the directory that contains <tt>.gitattributes</tt>
653 is from the path in question, the lower its precedence). Finally
654 global and system-wide files are considered (they have the lowest
655 precedence).</p></div>
656 <div class="paragraph"><p>If you wish to affect only a single repository (i.e., to assign
657 attributes to files that are particular to
658 one user&#8217;s workflow for that repository), then
659 attributes should be placed in the <tt>$GIT_DIR/info/attributes</tt> file.
660 Attributes which should be version-controlled and distributed to other
661 repositories (i.e., attributes of interest to all users) should go into
662 <tt>.gitattributes</tt> files. Attributes that should affect all repositories
663 for a single user should be placed in a file specified by the
664 <tt>core.attributesfile</tt> configuration option (see <a href="git-config.html">git-config(1)</a>).
665 Attributes for all users on a system should be placed in the
666 <tt>$(prefix)/etc/gitattributes</tt> file.</p></div>
667 <div class="paragraph"><p>Sometimes you would need to override an setting of an attribute
668 for a path to <tt>Unspecified</tt> state. This can be done by listing
669 the name of the attribute prefixed with an exclamation point <tt>!</tt>.</p></div>
670 </div>
671 <h2 id="_effects">EFFECTS</h2>
672 <div class="sectionbody">
673 <div class="paragraph"><p>Certain operations by git can be influenced by assigning
674 particular attributes to a path. Currently, the following
675 operations are attributes-aware.</p></div>
676 <h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3><div style="clear:left"></div>
677 <div class="paragraph"><p>These attributes affect how the contents stored in the
678 repository are copied to the working tree files when commands
679 such as <em>git checkout</em> and <em>git merge</em> run. They also affect how
680 git stores the contents you prepare in the working tree in the
681 repository upon <em>git add</em> and <em>git commit</em>.</p></div>
682 <h4 id="_tt_text_tt"><tt>text</tt></h4>
683 <div class="paragraph"><p>This attribute enables and controls end-of-line normalization. When a
684 text file is normalized, its line endings are converted to LF in the
685 repository. To control what line ending style is used in the working
686 directory, use the <tt>eol</tt> attribute for a single file and the
687 <tt>core.eol</tt> configuration variable for all text files.</p></div>
688 <div class="dlist"><dl>
689 <dt class="hdlist1">
691 </dt>
692 <dd>
694 Setting the <tt>text</tt> attribute on a path enables end-of-line
695 normalization and marks the path as a text file. End-of-line
696 conversion takes place without guessing the content type.
697 </p>
698 </dd>
699 <dt class="hdlist1">
700 Unset
701 </dt>
702 <dd>
704 Unsetting the <tt>text</tt> attribute on a path tells git not to
705 attempt any end-of-line conversion upon checkin or checkout.
706 </p>
707 </dd>
708 <dt class="hdlist1">
709 Set to string value "auto"
710 </dt>
711 <dd>
713 When <tt>text</tt> is set to "auto", the path is marked for automatic
714 end-of-line normalization. If git decides that the content is
715 text, its line endings are normalized to LF on checkin.
716 </p>
717 </dd>
718 <dt class="hdlist1">
719 Unspecified
720 </dt>
721 <dd>
723 If the <tt>text</tt> attribute is unspecified, git uses the
724 <tt>core.autocrlf</tt> configuration variable to determine if the
725 file should be converted.
726 </p>
727 </dd>
728 </dl></div>
729 <div class="paragraph"><p>Any other value causes git to act as if <tt>text</tt> has been left
730 unspecified.</p></div>
731 <h4 id="_tt_eol_tt"><tt>eol</tt></h4>
732 <div class="paragraph"><p>This attribute sets a specific line-ending style to be used in the
733 working directory. It enables end-of-line normalization without any
734 content checks, effectively setting the <tt>text</tt> attribute.</p></div>
735 <div class="dlist"><dl>
736 <dt class="hdlist1">
737 Set to string value "crlf"
738 </dt>
739 <dd>
741 This setting forces git to normalize line endings for this
742 file on checkin and convert them to CRLF when the file is
743 checked out.
744 </p>
745 </dd>
746 <dt class="hdlist1">
747 Set to string value "lf"
748 </dt>
749 <dd>
751 This setting forces git to normalize line endings to LF on
752 checkin and prevents conversion to CRLF when the file is
753 checked out.
754 </p>
755 </dd>
756 </dl></div>
757 <h4 id="_backwards_compatibility_with_tt_crlf_tt_attribute">Backwards compatibility with <tt>crlf</tt> attribute</h4>
758 <div class="paragraph"><p>For backwards compatibility, the <tt>crlf</tt> attribute is interpreted as
759 follows:</p></div>
760 <div class="listingblock">
761 <div class="content">
762 <pre><tt>crlf text
763 -crlf -text
764 crlf=input eol=lf</tt></pre>
765 </div></div>
766 <h4 id="_end_of_line_conversion">End-of-line conversion</h4>
767 <div class="paragraph"><p>While git normally leaves file contents alone, it can be configured to
768 normalize line endings to LF in the repository and, optionally, to
769 convert them to CRLF when files are checked out.</p></div>
770 <div class="paragraph"><p>Here is an example that will make git normalize .txt, .vcproj and .sh
771 files, ensure that .vcproj files have CRLF and .sh files have LF in
772 the working directory, and prevent .jpg files from being normalized
773 regardless of their content.</p></div>
774 <div class="listingblock">
775 <div class="content">
776 <pre><tt>*.txt text
777 *.vcproj eol=crlf
778 *.sh eol=lf
779 *.jpg -text</tt></pre>
780 </div></div>
781 <div class="paragraph"><p>Other source code management systems normalize all text files in their
782 repositories, and there are two ways to enable similar automatic
783 normalization in git.</p></div>
784 <div class="paragraph"><p>If you simply want to have CRLF line endings in your working directory
785 regardless of the repository you are working with, you can set the
786 config variable "core.autocrlf" without changing any attributes.</p></div>
787 <div class="listingblock">
788 <div class="content">
789 <pre><tt>[core]
790 autocrlf = true</tt></pre>
791 </div></div>
792 <div class="paragraph"><p>This does not force normalization of all text files, but does ensure
793 that text files that you introduce to the repository have their line
794 endings normalized to LF when they are added, and that files that are
795 already normalized in the repository stay normalized.</p></div>
796 <div class="paragraph"><p>If you want to interoperate with a source code management system that
797 enforces end-of-line normalization, or you simply want all text files
798 in your repository to be normalized, you should instead set the <tt>text</tt>
799 attribute to "auto" for <em>all</em> files.</p></div>
800 <div class="listingblock">
801 <div class="content">
802 <pre><tt>* text=auto</tt></pre>
803 </div></div>
804 <div class="paragraph"><p>This ensures that all files that git considers to be text will have
805 normalized (LF) line endings in the repository. The <tt>core.eol</tt>
806 configuration variable controls which line endings git will use for
807 normalized files in your working directory; the default is to use the
808 native line ending for your platform, or CRLF if <tt>core.autocrlf</tt> is
809 set.</p></div>
810 <div class="admonitionblock">
811 <table><tr>
812 <td class="icon">
813 <div class="title">Note</div>
814 </td>
815 <td class="content">When <tt>text=auto</tt> normalization is enabled in an existing
816 repository, any text files containing CRLFs should be normalized. If
817 they are not they will be normalized the next time someone tries to
818 change them, causing unfortunate misattribution. From a clean working
819 directory:</td>
820 </tr></table>
821 </div>
822 <div class="listingblock">
823 <div class="content">
824 <pre><tt>$ echo "* text=auto" &gt;&gt;.gitattributes
825 $ rm .git/index # Remove the index to force git to
826 $ git reset # re-scan the working directory
827 $ git status # Show files that will be normalized
828 $ git add -u
829 $ git add .gitattributes
830 $ git commit -m "Introduce end-of-line normalization"</tt></pre>
831 </div></div>
832 <div class="paragraph"><p>If any files that should not be normalized show up in <em>git status</em>,
833 unset their <tt>text</tt> attribute before running <em>git add -u</em>.</p></div>
834 <div class="listingblock">
835 <div class="content">
836 <pre><tt>manual.pdf -text</tt></pre>
837 </div></div>
838 <div class="paragraph"><p>Conversely, text files that git does not detect can have normalization
839 enabled manually.</p></div>
840 <div class="listingblock">
841 <div class="content">
842 <pre><tt>weirdchars.txt text</tt></pre>
843 </div></div>
844 <div class="paragraph"><p>If <tt>core.safecrlf</tt> is set to "true" or "warn", git verifies if
845 the conversion is reversible for the current setting of
846 <tt>core.autocrlf</tt>. For "true", git rejects irreversible
847 conversions; for "warn", git only prints a warning but accepts
848 an irreversible conversion. The safety triggers to prevent such
849 a conversion done to the files in the work tree, but there are a
850 few exceptions. Even though&#8230;</p></div>
851 <div class="ulist"><ul>
852 <li>
854 <em>git add</em> itself does not touch the files in the work tree, the
855 next checkout would, so the safety triggers;
856 </p>
857 </li>
858 <li>
860 <em>git apply</em> to update a text file with a patch does touch the files
861 in the work tree, but the operation is about text files and CRLF
862 conversion is about fixing the line ending inconsistencies, so the
863 safety does not trigger;
864 </p>
865 </li>
866 <li>
868 <em>git diff</em> itself does not touch the files in the work tree, it is
869 often run to inspect the changes you intend to next <em>git add</em>. To
870 catch potential problems early, safety triggers.
871 </p>
872 </li>
873 </ul></div>
874 <h4 id="_tt_ident_tt"><tt>ident</tt></h4>
875 <div class="paragraph"><p>When the attribute <tt>ident</tt> is set for a path, git replaces
876 <tt>$Id$</tt> in the blob object with <tt>$Id:</tt>, followed by the
877 40-character hexadecimal blob object name, followed by a dollar
878 sign <tt>$</tt> upon checkout. Any byte sequence that begins with
879 <tt>$Id:</tt> and ends with <tt>$</tt> in the worktree file is replaced
880 with <tt>$Id$</tt> upon check-in.</p></div>
881 <h4 id="_tt_filter_tt"><tt>filter</tt></h4>
882 <div class="paragraph"><p>A <tt>filter</tt> attribute can be set to a string value that names a
883 filter driver specified in the configuration.</p></div>
884 <div class="paragraph"><p>A filter driver consists of a <tt>clean</tt> command and a <tt>smudge</tt>
885 command, either of which can be left unspecified. Upon
886 checkout, when the <tt>smudge</tt> command is specified, the command is
887 fed the blob object from its standard input, and its standard
888 output is used to update the worktree file. Similarly, the
889 <tt>clean</tt> command is used to convert the contents of worktree file
890 upon checkin.</p></div>
891 <div class="paragraph"><p>A missing filter driver definition in the config is not an error
892 but makes the filter a no-op passthru.</p></div>
893 <div class="paragraph"><p>The content filtering is done to massage the content into a
894 shape that is more convenient for the platform, filesystem, and
895 the user to use. The key phrase here is "more convenient" and not
896 "turning something unusable into usable". In other words, the
897 intent is that if someone unsets the filter driver definition,
898 or does not have the appropriate filter program, the project
899 should still be usable.</p></div>
900 <div class="paragraph"><p>For example, in .gitattributes, you would assign the <tt>filter</tt>
901 attribute for paths.</p></div>
902 <div class="listingblock">
903 <div class="content">
904 <pre><tt>*.c filter=indent</tt></pre>
905 </div></div>
906 <div class="paragraph"><p>Then you would define a "filter.indent.clean" and "filter.indent.smudge"
907 configuration in your .git/config to specify a pair of commands to
908 modify the contents of C programs when the source files are checked
909 in ("clean" is run) and checked out (no change is made because the
910 command is "cat").</p></div>
911 <div class="listingblock">
912 <div class="content">
913 <pre><tt>[filter "indent"]
914 clean = indent
915 smudge = cat</tt></pre>
916 </div></div>
917 <div class="paragraph"><p>For best results, <tt>clean</tt> should not alter its output further if it is
918 run twice ("clean&#8594;clean" should be equivalent to "clean"), and
919 multiple <tt>smudge</tt> commands should not alter <tt>clean</tt>'s output
920 ("smudge&#8594;smudge&#8594;clean" should be equivalent to "clean"). See the
921 section on merging below.</p></div>
922 <div class="paragraph"><p>The "indent" filter is well-behaved in this regard: it will not modify
923 input that is already correctly indented. In this case, the lack of a
924 smudge filter means that the clean filter <em>must</em> accept its own output
925 without modifying it.</p></div>
926 <div class="paragraph"><p>Sequence "%f" on the filter command line is replaced with the name of
927 the file the filter is working on. A filter might use this in keyword
928 substitution. For example:</p></div>
929 <div class="listingblock">
930 <div class="content">
931 <pre><tt>[filter "p4"]
932 clean = git-p4-filter --clean %f
933 smudge = git-p4-filter --smudge %f</tt></pre>
934 </div></div>
935 <h4 id="_interaction_between_checkin_checkout_attributes">Interaction between checkin/checkout attributes</h4>
936 <div class="paragraph"><p>In the check-in codepath, the worktree file is first converted
937 with <tt>filter</tt> driver (if specified and corresponding driver
938 defined), then the result is processed with <tt>ident</tt> (if
939 specified), and then finally with <tt>text</tt> (again, if specified
940 and applicable).</p></div>
941 <div class="paragraph"><p>In the check-out codepath, the blob content is first converted
942 with <tt>text</tt>, and then <tt>ident</tt> and fed to <tt>filter</tt>.</p></div>
943 <h4 id="_merging_branches_with_differing_checkin_checkout_attributes">Merging branches with differing checkin/checkout attributes</h4>
944 <div class="paragraph"><p>If you have added attributes to a file that cause the canonical
945 repository format for that file to change, such as adding a
946 clean/smudge filter or text/eol/ident attributes, merging anything
947 where the attribute is not in place would normally cause merge
948 conflicts.</p></div>
949 <div class="paragraph"><p>To prevent these unnecessary merge conflicts, git can be told to run a
950 virtual check-out and check-in of all three stages of a file when
951 resolving a three-way merge by setting the <tt>merge.renormalize</tt>
952 configuration variable. This prevents changes caused by check-in
953 conversion from causing spurious merge conflicts when a converted file
954 is merged with an unconverted file.</p></div>
955 <div class="paragraph"><p>As long as a "smudge&#8594;clean" results in the same output as a "clean"
956 even on files that are already smudged, this strategy will
957 automatically resolve all filter-related conflicts. Filters that do
958 not act in this way may cause additional merge conflicts that must be
959 resolved manually.</p></div>
960 <h3 id="_generating_diff_text">Generating diff text</h3><div style="clear:left"></div>
961 <h4 id="_tt_diff_tt"><tt>diff</tt></h4>
962 <div class="paragraph"><p>The attribute <tt>diff</tt> affects how <em>git</em> generates diffs for particular
963 files. It can tell git whether to generate a textual patch for the path
964 or to treat the path as a binary file. It can also affect what line is
965 shown on the hunk header <tt>@@ -k,l +n,m @@</tt> line, tell git to use an
966 external command to generate the diff, or ask git to convert binary
967 files to a text format before generating the diff.</p></div>
968 <div class="dlist"><dl>
969 <dt class="hdlist1">
971 </dt>
972 <dd>
974 A path to which the <tt>diff</tt> attribute is set is treated
975 as text, even when they contain byte values that
976 normally never appear in text files, such as NUL.
977 </p>
978 </dd>
979 <dt class="hdlist1">
980 Unset
981 </dt>
982 <dd>
984 A path to which the <tt>diff</tt> attribute is unset will
985 generate <tt>Binary files differ</tt> (or a binary patch, if
986 binary patches are enabled).
987 </p>
988 </dd>
989 <dt class="hdlist1">
990 Unspecified
991 </dt>
992 <dd>
994 A path to which the <tt>diff</tt> attribute is unspecified
995 first gets its contents inspected, and if it looks like
996 text, it is treated as text. Otherwise it would
997 generate <tt>Binary files differ</tt>.
998 </p>
999 </dd>
1000 <dt class="hdlist1">
1001 String
1002 </dt>
1003 <dd>
1005 Diff is shown using the specified diff driver. Each driver may
1006 specify one or more options, as described in the following
1007 section. The options for the diff driver "foo" are defined
1008 by the configuration variables in the "diff.foo" section of the
1009 git config file.
1010 </p>
1011 </dd>
1012 </dl></div>
1013 <h4 id="_defining_an_external_diff_driver">Defining an external diff driver</h4>
1014 <div class="paragraph"><p>The definition of a diff driver is done in <tt>gitconfig</tt>, not
1015 <tt>gitattributes</tt> file, so strictly speaking this manual page is a
1016 wrong place to talk about it. However&#8230;</p></div>
1017 <div class="paragraph"><p>To define an external diff driver <tt>jcdiff</tt>, add a section to your
1018 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
1019 <div class="listingblock">
1020 <div class="content">
1021 <pre><tt>[diff "jcdiff"]
1022 command = j-c-diff</tt></pre>
1023 </div></div>
1024 <div class="paragraph"><p>When git needs to show you a diff for the path with <tt>diff</tt>
1025 attribute set to <tt>jcdiff</tt>, it calls the command you specified
1026 with the above configuration, i.e. <tt>j-c-diff</tt>, with 7
1027 parameters, just like <tt>GIT_EXTERNAL_DIFF</tt> program is called.
1028 See <a href="git.html">git(1)</a> for details.</p></div>
1029 <h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4>
1030 <div class="paragraph"><p>Each group of changes (called a "hunk") in the textual diff output
1031 is prefixed with a line of the form:</p></div>
1032 <div class="literalblock">
1033 <div class="content">
1034 <pre><tt>@@ -k,l +n,m @@ TEXT</tt></pre>
1035 </div></div>
1036 <div class="paragraph"><p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line
1037 that begins with an alphabet, an underscore or a dollar sign; this
1038 matches what GNU <em>diff -p</em> output uses. This default selection however
1039 is not suited for some contents, and you can use a customized pattern
1040 to make a selection.</p></div>
1041 <div class="paragraph"><p>First, in .gitattributes, you would assign the <tt>diff</tt> attribute
1042 for paths.</p></div>
1043 <div class="listingblock">
1044 <div class="content">
1045 <pre><tt>*.tex diff=tex</tt></pre>
1046 </div></div>
1047 <div class="paragraph"><p>Then, you would define a "diff.tex.xfuncname" configuration to
1048 specify a regular expression that matches a line that you would
1049 want to appear as the hunk header "TEXT". Add a section to your
1050 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
1051 <div class="listingblock">
1052 <div class="content">
1053 <pre><tt>[diff "tex"]
1054 xfuncname = "^(\\\\(sub)*section\\{.*)$"</tt></pre>
1055 </div></div>
1056 <div class="paragraph"><p>Note. A single level of backslashes are eaten by the
1057 configuration file parser, so you would need to double the
1058 backslashes; the pattern above picks a line that begins with a
1059 backslash, and zero or more occurrences of <tt>sub</tt> followed by
1060 <tt>section</tt> followed by open brace, to the end of line.</p></div>
1061 <div class="paragraph"><p>There are a few built-in patterns to make this easier, and <tt>tex</tt>
1062 is one of them, so you do not have to write the above in your
1063 configuration file (you still need to enable this with the
1064 attribute mechanism, via <tt>.gitattributes</tt>). The following built in
1065 patterns are available:</p></div>
1066 <div class="ulist"><ul>
1067 <li>
1069 <tt>bibtex</tt> suitable for files with BibTeX coded references.
1070 </p>
1071 </li>
1072 <li>
1074 <tt>cpp</tt> suitable for source code in the C and C++ languages.
1075 </p>
1076 </li>
1077 <li>
1079 <tt>csharp</tt> suitable for source code in the C# language.
1080 </p>
1081 </li>
1082 <li>
1084 <tt>fortran</tt> suitable for source code in the Fortran language.
1085 </p>
1086 </li>
1087 <li>
1089 <tt>html</tt> suitable for HTML/XHTML documents.
1090 </p>
1091 </li>
1092 <li>
1094 <tt>java</tt> suitable for source code in the Java language.
1095 </p>
1096 </li>
1097 <li>
1099 <tt>objc</tt> suitable for source code in the Objective-C language.
1100 </p>
1101 </li>
1102 <li>
1104 <tt>pascal</tt> suitable for source code in the Pascal/Delphi language.
1105 </p>
1106 </li>
1107 <li>
1109 <tt>perl</tt> suitable for source code in the Perl language.
1110 </p>
1111 </li>
1112 <li>
1114 <tt>php</tt> suitable for source code in the PHP language.
1115 </p>
1116 </li>
1117 <li>
1119 <tt>python</tt> suitable for source code in the Python language.
1120 </p>
1121 </li>
1122 <li>
1124 <tt>ruby</tt> suitable for source code in the Ruby language.
1125 </p>
1126 </li>
1127 <li>
1129 <tt>tex</tt> suitable for source code for LaTeX documents.
1130 </p>
1131 </li>
1132 </ul></div>
1133 <h4 id="_customizing_word_diff">Customizing word diff</h4>
1134 <div class="paragraph"><p>You can customize the rules that <tt>git diff --word-diff</tt> uses to
1135 split words in a line, by specifying an appropriate regular expression
1136 in the "diff.*.wordRegex" configuration variable. For example, in TeX
1137 a backslash followed by a sequence of letters forms a command, but
1138 several such commands can be run together without intervening
1139 whitespace. To separate them, use a regular expression in your
1140 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
1141 <div class="listingblock">
1142 <div class="content">
1143 <pre><tt>[diff "tex"]
1144 wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</tt></pre>
1145 </div></div>
1146 <div class="paragraph"><p>A built-in pattern is provided for all languages listed in the
1147 previous section.</p></div>
1148 <h4 id="_performing_text_diffs_of_binary_files">Performing text diffs of binary files</h4>
1149 <div class="paragraph"><p>Sometimes it is desirable to see the diff of a text-converted
1150 version of some binary files. For example, a word processor
1151 document can be converted to an ASCII text representation, and
1152 the diff of the text shown. Even though this conversion loses
1153 some information, the resulting diff is useful for human
1154 viewing (but cannot be applied directly).</p></div>
1155 <div class="paragraph"><p>The <tt>textconv</tt> config option is used to define a program for
1156 performing such a conversion. The program should take a single
1157 argument, the name of a file to convert, and produce the
1158 resulting text on stdout.</p></div>
1159 <div class="paragraph"><p>For example, to show the diff of the exif information of a
1160 file instead of the binary information (assuming you have the
1161 exif tool installed), add the following section to your
1162 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file):</p></div>
1163 <div class="listingblock">
1164 <div class="content">
1165 <pre><tt>[diff "jpg"]
1166 textconv = exif</tt></pre>
1167 </div></div>
1168 <div class="admonitionblock">
1169 <table><tr>
1170 <td class="icon">
1171 <div class="title">Note</div>
1172 </td>
1173 <td class="content">The text conversion is generally a one-way conversion;
1174 in this example, we lose the actual image contents and focus
1175 just on the text data. This means that diffs generated by
1176 textconv are <em>not</em> suitable for applying. For this reason,
1177 only <tt>git diff</tt> and the <tt>git log</tt> family of commands (i.e.,
1178 log, whatchanged, show) will perform text conversion. <tt>git
1179 format-patch</tt> will never generate this output. If you want to
1180 send somebody a text-converted diff of a binary file (e.g.,
1181 because it quickly conveys the changes you have made), you
1182 should generate it separately and send it as a comment <em>in
1183 addition to</em> the usual binary diff that you might send.</td>
1184 </tr></table>
1185 </div>
1186 <div class="paragraph"><p>Because text conversion can be slow, especially when doing a
1187 large number of them with <tt>git log -p</tt>, git provides a mechanism
1188 to cache the output and use it in future diffs. To enable
1189 caching, set the "cachetextconv" variable in your diff driver&#8217;s
1190 config. For example:</p></div>
1191 <div class="listingblock">
1192 <div class="content">
1193 <pre><tt>[diff "jpg"]
1194 textconv = exif
1195 cachetextconv = true</tt></pre>
1196 </div></div>
1197 <div class="paragraph"><p>This will cache the result of running "exif" on each blob
1198 indefinitely. If you change the textconv config variable for a
1199 diff driver, git will automatically invalidate the cache entries
1200 and re-run the textconv filter. If you want to invalidate the
1201 cache manually (e.g., because your version of "exif" was updated
1202 and now produces better output), you can remove the cache
1203 manually with <tt>git update-ref -d refs/notes/textconv/jpg</tt> (where
1204 "jpg" is the name of the diff driver, as in the example above).</p></div>
1205 <h4 id="_choosing_textconv_versus_external_diff">Choosing textconv versus external diff</h4>
1206 <div class="paragraph"><p>If you want to show differences between binary or specially-formatted
1207 blobs in your repository, you can choose to use either an external diff
1208 command, or to use textconv to convert them to a diff-able text format.
1209 Which method you choose depends on your exact situation.</p></div>
1210 <div class="paragraph"><p>The advantage of using an external diff command is flexibility. You are
1211 not bound to find line-oriented changes, nor is it necessary for the
1212 output to resemble unified diff. You are free to locate and report
1213 changes in the most appropriate way for your data format.</p></div>
1214 <div class="paragraph"><p>A textconv, by comparison, is much more limiting. You provide a
1215 transformation of the data into a line-oriented text format, and git
1216 uses its regular diff tools to generate the output. There are several
1217 advantages to choosing this method:</p></div>
1218 <div class="olist arabic"><ol class="arabic">
1219 <li>
1221 Ease of use. It is often much simpler to write a binary to text
1222 transformation than it is to perform your own diff. In many cases,
1223 existing programs can be used as textconv filters (e.g., exif,
1224 odt2txt).
1225 </p>
1226 </li>
1227 <li>
1229 Git diff features. By performing only the transformation step
1230 yourself, you can still utilize many of git&#8217;s diff features,
1231 including colorization, word-diff, and combined diffs for merges.
1232 </p>
1233 </li>
1234 <li>
1236 Caching. Textconv caching can speed up repeated diffs, such as those
1237 you might trigger by running <tt>git log -p</tt>.
1238 </p>
1239 </li>
1240 </ol></div>
1241 <h4 id="_marking_files_as_binary">Marking files as binary</h4>
1242 <div class="paragraph"><p>Git usually guesses correctly whether a blob contains text or binary
1243 data by examining the beginning of the contents. However, sometimes you
1244 may want to override its decision, either because a blob contains binary
1245 data later in the file, or because the content, while technically
1246 composed of text characters, is opaque to a human reader. For example,
1247 many postscript files contain only ascii characters, but produce noisy
1248 and meaningless diffs.</p></div>
1249 <div class="paragraph"><p>The simplest way to mark a file as binary is to unset the diff
1250 attribute in the <tt>.gitattributes</tt> file:</p></div>
1251 <div class="listingblock">
1252 <div class="content">
1253 <pre><tt>*.ps -diff</tt></pre>
1254 </div></div>
1255 <div class="paragraph"><p>This will cause git to generate <tt>Binary files differ</tt> (or a binary
1256 patch, if binary patches are enabled) instead of a regular diff.</p></div>
1257 <div class="paragraph"><p>However, one may also want to specify other diff driver attributes. For
1258 example, you might want to use <tt>textconv</tt> to convert postscript files to
1259 an ascii representation for human viewing, but otherwise treat them as
1260 binary files. You cannot specify both <tt>-diff</tt> and <tt>diff=ps</tt> attributes.
1261 The solution is to use the <tt>diff.*.binary</tt> config option:</p></div>
1262 <div class="listingblock">
1263 <div class="content">
1264 <pre><tt>[diff "ps"]
1265 textconv = ps2ascii
1266 binary = true</tt></pre>
1267 </div></div>
1268 <h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3><div style="clear:left"></div>
1269 <h4 id="_tt_merge_tt"><tt>merge</tt></h4>
1270 <div class="paragraph"><p>The attribute <tt>merge</tt> affects how three versions of a file are
1271 merged when a file-level merge is necessary during <tt>git merge</tt>,
1272 and other commands such as <tt>git revert</tt> and <tt>git cherry-pick</tt>.</p></div>
1273 <div class="dlist"><dl>
1274 <dt class="hdlist1">
1276 </dt>
1277 <dd>
1279 Built-in 3-way merge driver is used to merge the
1280 contents in a way similar to <em>merge</em> command of <tt>RCS</tt>
1281 suite. This is suitable for ordinary text files.
1282 </p>
1283 </dd>
1284 <dt class="hdlist1">
1285 Unset
1286 </dt>
1287 <dd>
1289 Take the version from the current branch as the
1290 tentative merge result, and declare that the merge has
1291 conflicts. This is suitable for binary files that do
1292 not have a well-defined merge semantics.
1293 </p>
1294 </dd>
1295 <dt class="hdlist1">
1296 Unspecified
1297 </dt>
1298 <dd>
1300 By default, this uses the same built-in 3-way merge
1301 driver as is the case when the <tt>merge</tt> attribute is set.
1302 However, the <tt>merge.default</tt> configuration variable can name
1303 different merge driver to be used with paths for which the
1304 <tt>merge</tt> attribute is unspecified.
1305 </p>
1306 </dd>
1307 <dt class="hdlist1">
1308 String
1309 </dt>
1310 <dd>
1312 3-way merge is performed using the specified custom
1313 merge driver. The built-in 3-way merge driver can be
1314 explicitly specified by asking for "text" driver; the
1315 built-in "take the current branch" driver can be
1316 requested with "binary".
1317 </p>
1318 </dd>
1319 </dl></div>
1320 <h4 id="_built_in_merge_drivers">Built-in merge drivers</h4>
1321 <div class="paragraph"><p>There are a few built-in low-level merge drivers defined that
1322 can be asked for via the <tt>merge</tt> attribute.</p></div>
1323 <div class="dlist"><dl>
1324 <dt class="hdlist1">
1325 text
1326 </dt>
1327 <dd>
1329 Usual 3-way file level merge for text files. Conflicted
1330 regions are marked with conflict markers <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt>,
1331 <tt>=======</tt> and <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt>. The version from your branch
1332 appears before the <tt>=======</tt> marker, and the version
1333 from the merged branch appears after the <tt>=======</tt>
1334 marker.
1335 </p>
1336 </dd>
1337 <dt class="hdlist1">
1338 binary
1339 </dt>
1340 <dd>
1342 Keep the version from your branch in the work tree, but
1343 leave the path in the conflicted state for the user to
1344 sort out.
1345 </p>
1346 </dd>
1347 <dt class="hdlist1">
1348 union
1349 </dt>
1350 <dd>
1352 Run 3-way file level merge for text files, but take
1353 lines from both versions, instead of leaving conflict
1354 markers. This tends to leave the added lines in the
1355 resulting file in random order and the user should
1356 verify the result. Do not use this if you do not
1357 understand the implications.
1358 </p>
1359 </dd>
1360 </dl></div>
1361 <h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4>
1362 <div class="paragraph"><p>The definition of a merge driver is done in the <tt>.git/config</tt>
1363 file, not in the <tt>gitattributes</tt> file, so strictly speaking this
1364 manual page is a wrong place to talk about it. However&#8230;</p></div>
1365 <div class="paragraph"><p>To define a custom merge driver <tt>filfre</tt>, add a section to your
1366 <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
1367 <div class="listingblock">
1368 <div class="content">
1369 <pre><tt>[merge "filfre"]
1370 name = feel-free merge driver
1371 driver = filfre %O %A %B
1372 recursive = binary</tt></pre>
1373 </div></div>
1374 <div class="paragraph"><p>The <tt>merge.*.name</tt> variable gives the driver a human-readable
1375 name.</p></div>
1376 <div class="paragraph"><p>The &#8216;merge.*.driver` variable&#8217;s value is used to construct a
1377 command to run to merge ancestor&#8217;s version (<tt>%O</tt>), current
1378 version (<tt>%A</tt>) and the other branches&#8217; version (<tt>%B</tt>). These
1379 three tokens are replaced with the names of temporary files that
1380 hold the contents of these versions when the command line is
1381 built. Additionally, %L will be replaced with the conflict marker
1382 size (see below).</p></div>
1383 <div class="paragraph"><p>The merge driver is expected to leave the result of the merge in
1384 the file named with <tt>%A</tt> by overwriting it, and exit with zero
1385 status if it managed to merge them cleanly, or non-zero if there
1386 were conflicts.</p></div>
1387 <div class="paragraph"><p>The <tt>merge.*.recursive</tt> variable specifies what other merge
1388 driver to use when the merge driver is called for an internal
1389 merge between common ancestors, when there are more than one.
1390 When left unspecified, the driver itself is used for both
1391 internal merge and the final merge.</p></div>
1392 <h4 id="_tt_conflict_marker_size_tt"><tt>conflict-marker-size</tt></h4>
1393 <div class="paragraph"><p>This attribute controls the length of conflict markers left in
1394 the work tree file during a conflicted merge. Only setting to
1395 the value to a positive integer has any meaningful effect.</p></div>
1396 <div class="paragraph"><p>For example, this line in <tt>.gitattributes</tt> can be used to tell the merge
1397 machinery to leave much longer (instead of the usual 7-character-long)
1398 conflict markers when merging the file <tt>Documentation/git-merge.txt</tt>
1399 results in a conflict.</p></div>
1400 <div class="listingblock">
1401 <div class="content">
1402 <pre><tt>Documentation/git-merge.txt conflict-marker-size=32</tt></pre>
1403 </div></div>
1404 <h3 id="_checking_whitespace_errors">Checking whitespace errors</h3><div style="clear:left"></div>
1405 <h4 id="_tt_whitespace_tt"><tt>whitespace</tt></h4>
1406 <div class="paragraph"><p>The <tt>core.whitespace</tt> configuration variable allows you to define what
1407 <em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in
1408 the project (See <a href="git-config.html">git-config(1)</a>). This attribute gives you finer
1409 control per path.</p></div>
1410 <div class="dlist"><dl>
1411 <dt class="hdlist1">
1413 </dt>
1414 <dd>
1416 Notice all types of potential whitespace errors known to git.
1417 The tab width is taken from the value of the <tt>core.whitespace</tt>
1418 configuration variable.
1419 </p>
1420 </dd>
1421 <dt class="hdlist1">
1422 Unset
1423 </dt>
1424 <dd>
1426 Do not notice anything as error.
1427 </p>
1428 </dd>
1429 <dt class="hdlist1">
1430 Unspecified
1431 </dt>
1432 <dd>
1434 Use the value of the <tt>core.whitespace</tt> configuration variable to
1435 decide what to notice as error.
1436 </p>
1437 </dd>
1438 <dt class="hdlist1">
1439 String
1440 </dt>
1441 <dd>
1443 Specify a comma separate list of common whitespace problems to
1444 notice in the same format as the <tt>core.whitespace</tt> configuration
1445 variable.
1446 </p>
1447 </dd>
1448 </dl></div>
1449 <h3 id="_creating_an_archive">Creating an archive</h3><div style="clear:left"></div>
1450 <h4 id="_tt_export_ignore_tt"><tt>export-ignore</tt></h4>
1451 <div class="paragraph"><p>Files and directories with the attribute <tt>export-ignore</tt> won&#8217;t be added to
1452 archive files.</p></div>
1453 <h4 id="_tt_export_subst_tt"><tt>export-subst</tt></h4>
1454 <div class="paragraph"><p>If the attribute <tt>export-subst</tt> is set for a file then git will expand
1455 several placeholders when adding this file to an archive. The
1456 expansion depends on the availability of a commit ID, i.e., if
1457 <a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a
1458 tag then no replacement will be done. The placeholders are the same
1459 as those for the option <tt>--pretty=format:</tt> of <a href="git-log.html">git-log(1)</a>,
1460 except that they need to be wrapped like this: <tt>$Format:PLACEHOLDERS$</tt>
1461 in the file. E.g. the string <tt>$Format:%H$</tt> will be replaced by the
1462 commit hash.</p></div>
1463 <h3 id="_packing_objects">Packing objects</h3><div style="clear:left"></div>
1464 <h4 id="_tt_delta_tt"><tt>delta</tt></h4>
1465 <div class="paragraph"><p>Delta compression will not be attempted for blobs for paths with the
1466 attribute <tt>delta</tt> set to false.</p></div>
1467 <h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3><div style="clear:left"></div>
1468 <h4 id="_tt_encoding_tt"><tt>encoding</tt></h4>
1469 <div class="paragraph"><p>The value of this attribute specifies the character encoding that should
1470 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
1471 display the contents of the relevant file. Note that due to performance
1472 considerations <a href="gitk.html">gitk(1)</a> does not use this attribute unless you
1473 manually enable per-file encodings in its options.</p></div>
1474 <div class="paragraph"><p>If this attribute is not set or has an invalid value, the value of the
1475 <tt>gui.encoding</tt> configuration variable is used instead
1476 (See <a href="git-config.html">git-config(1)</a>).</p></div>
1477 </div>
1478 <h2 id="_using_macro_attributes">USING MACRO ATTRIBUTES</h2>
1479 <div class="sectionbody">
1480 <div class="paragraph"><p>You do not want any end-of-line conversions applied to, nor textual diffs
1481 produced for, any binary file you track. You would need to specify e.g.</p></div>
1482 <div class="listingblock">
1483 <div class="content">
1484 <pre><tt>*.jpg -text -diff</tt></pre>
1485 </div></div>
1486 <div class="paragraph"><p>but that may become cumbersome, when you have many attributes. Using
1487 macro attributes, you can define an attribute that, when set, also
1488 sets or unsets a number of other attributes at the same time. The
1489 system knows a built-in macro attribute, <tt>binary</tt>:</p></div>
1490 <div class="listingblock">
1491 <div class="content">
1492 <pre><tt>*.jpg binary</tt></pre>
1493 </div></div>
1494 <div class="paragraph"><p>Setting the "binary" attribute also unsets the "text" and "diff"
1495 attributes as above. Note that macro attributes can only be "Set",
1496 though setting one might have the effect of setting or unsetting other
1497 attributes or even returning other attributes to the "Unspecified"
1498 state.</p></div>
1499 </div>
1500 <h2 id="_defining_macro_attributes">DEFINING MACRO ATTRIBUTES</h2>
1501 <div class="sectionbody">
1502 <div class="paragraph"><p>Custom macro attributes can be defined only in the <tt>.gitattributes</tt>
1503 file at the toplevel (i.e. not in any subdirectory). The built-in
1504 macro attribute "binary" is equivalent to:</p></div>
1505 <div class="listingblock">
1506 <div class="content">
1507 <pre><tt>[attr]binary -diff -text</tt></pre>
1508 </div></div>
1509 </div>
1510 <h2 id="_example">EXAMPLE</h2>
1511 <div class="sectionbody">
1512 <div class="paragraph"><p>If you have these three <tt>gitattributes</tt> file:</p></div>
1513 <div class="listingblock">
1514 <div class="content">
1515 <pre><tt>(in $GIT_DIR/info/attributes)
1517 a* foo !bar -baz
1519 (in .gitattributes)
1520 abc foo bar baz
1522 (in t/.gitattributes)
1523 ab* merge=filfre
1524 abc -foo -bar
1525 *.c frotz</tt></pre>
1526 </div></div>
1527 <div class="paragraph"><p>the attributes given to path <tt>t/abc</tt> are computed as follows:</p></div>
1528 <div class="olist arabic"><ol class="arabic">
1529 <li>
1531 By examining <tt>t/.gitattributes</tt> (which is in the same
1532 directory as the path in question), git finds that the first
1533 line matches. <tt>merge</tt> attribute is set. It also finds that
1534 the second line matches, and attributes <tt>foo</tt> and <tt>bar</tt>
1535 are unset.
1536 </p>
1537 </li>
1538 <li>
1540 Then it examines <tt>.gitattributes</tt> (which is in the parent
1541 directory), and finds that the first line matches, but
1542 <tt>t/.gitattributes</tt> file already decided how <tt>merge</tt>, <tt>foo</tt>
1543 and <tt>bar</tt> attributes should be given to this path, so it
1544 leaves <tt>foo</tt> and <tt>bar</tt> unset. Attribute <tt>baz</tt> is set.
1545 </p>
1546 </li>
1547 <li>
1549 Finally it examines <tt>$GIT_DIR/info/attributes</tt>. This file
1550 is used to override the in-tree settings. The first line is
1551 a match, and <tt>foo</tt> is set, <tt>bar</tt> is reverted to unspecified
1552 state, and <tt>baz</tt> is unset.
1553 </p>
1554 </li>
1555 </ol></div>
1556 <div class="paragraph"><p>As the result, the attributes assignment to <tt>t/abc</tt> becomes:</p></div>
1557 <div class="listingblock">
1558 <div class="content">
1559 <pre><tt>foo set to true
1560 bar unspecified
1561 baz set to false
1562 merge set to string value "filfre"
1563 frotz unspecified</tt></pre>
1564 </div></div>
1565 </div>
1566 <h2 id="_see_also">SEE ALSO</h2>
1567 <div class="sectionbody">
1568 <div class="paragraph"><p><a href="git-check-attr.html">git-check-attr(1)</a>.</p></div>
1569 </div>
1570 <h2 id="_git">GIT</h2>
1571 <div class="sectionbody">
1572 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1573 </div>
1574 </div>
1575 <div id="footnotes"><hr /></div>
1576 <div id="footer">
1577 <div id="footer-text">
1578 Last updated 2011-09-21 23:01:14 PDT
1579 </div>
1580 </div>
1581 </body>
1582 </html>