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">
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">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.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
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.0em;
131 div
.content
{ /* Block element content. */
135 /* Block element titles. */
136 div
.title
, caption
.title
{
138 font-family: sans-serif
;
142 margin-bottom: 0.5em;
148 td div
.title:first-child
{
151 div
.content div
.title:first-child
{
154 div
.content
+ div
.title
{
158 div
.sidebarblock
> div
.content
{
160 border: 1px solid silver
;
164 div
.listingblock
> div
.content
{
165 border: 1px solid silver
;
170 div
.quoteblock
, div
.verseblock
{
174 border-left: 5px solid
#dddddd;
178 div
.quoteblock
> div
.attribution
{
183 div
.verseblock
> div
.content
{
186 div
.verseblock
> div
.attribution
{
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div
.verseblock
+ div
.attribution
{
195 div
.admonitionblock
.icon
{
199 text-decoration: underline
;
201 padding-right: 0.5em;
203 div
.admonitionblock td
.content
{
205 border-left: 3px solid
#dddddd;
208 div
.exampleblock
> div
.content
{
209 border-left: 3px solid
#dddddd;
213 div
.imageblock div
.content
{ padding-left: 0; }
214 span
.image img
{ border-style: none
; }
215 a
.image:visited
{ color: white
; }
219 margin-bottom: 0.8em;
232 list-style-position: outside
;
235 list-style-type: decimal
;
238 list-style-type: lower-alpha
;
241 list-style-type: upper-alpha
;
244 list-style-type: lower-roman
;
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
{
254 margin-bottom: 0.1em;
257 div
.tableblock
> table
{
258 border: 3px solid
#527bbd;
260 thead
, p
.table
.header
{
261 font-family: sans-serif
;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div
.tableblock
> table
[frame
="void"] {
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
;
289 margin-bottom: 0.8em;
292 padding-bottom: 15px;
294 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
300 padding-right: 0.8em;
306 div
.hdlist
.compact tr
{
315 .footnote, .footnoteref {
319 span
.footnote
, span
.footnoteref
{
320 vertical-align: super
;
324 margin: 20px 0 20px 0;
328 #footnotes div
.footnote
{
334 border-top: 1px solid silver
;
344 div#footer-badges
{ display: none
; }
348 margin-bottom: 2.5em;
353 font-family: sans-serif
;
357 margin-bottom: 0.1em;
360 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
376 /* Overrides for manpage documents */
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver
;
381 border-bottom: 2px solid silver
;
391 div#toc
{ display: none
; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div
.sidebar-content
{
398 border: 1px solid silver
;
401 div
.sidebar-title
, div
.image-title
{
403 font-family: sans-serif
;
406 margin-bottom: 0.5em;
409 div
.listingblock div
.content
{
410 border: 1px solid silver
;
415 div
.quoteblock-attribution
{
420 div
.verseblock-content
{
423 div
.verseblock-attribution
{
428 div
.exampleblock-content
{
429 border-left: 3px solid
#dddddd;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc
a:visited
{ color: blue
; }
436 <script type=
"text/javascript">
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
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 */
459 toc: function (toclevels
) {
461 function getText(el
) {
463 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
464 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
466 else if (i
.firstChild
!= null)
472 function TocEntry(el
, text
, toclevel
) {
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
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);
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");
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");
532 for (i
=0; i
<spans
.length
; i
++) {
533 if (spans
[i
].className
== "footnote") {
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>";
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
;
550 noteholder
.parentNode
.removeChild(noteholder
);
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.
559 "[<a href='#_footnote_" + n
+
560 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
573 gitattributes(
5) Manual Page
576 <div class=
"sectionbody">
578 defining attributes per path
583 <h2 id=
"_synopsis">SYNOPSIS
</h2>
584 <div class=
"sectionbody">
585 <div class=
"paragraph"><p>$GIT_DIR/info/attributes, .gitattributes
</p></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>
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
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>
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.
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.
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
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.
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
’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>
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>
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.
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.
709 Set to string value
"auto"
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.
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.
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>
737 Set to string value
"crlf"
741 This setting forces git to normalize line endings for this
742 file on checkin and convert them to CRLF when the file is
747 Set to string value
"lf"
751 This setting forces git to normalize line endings to LF on
752 checkin and prevents conversion to CRLF when the file is
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
760 <div class=
"listingblock">
761 <div class=
"content">
764 crlf=input eol=lf
</tt></pre>
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">
779 *.jpg -text
</tt></pre>
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">
790 autocrlf = true
</tt></pre>
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>
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
810 <div class=
"admonitionblock">
813 <div class=
"title">Note
</div>
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
822 <div class=
"listingblock">
823 <div class=
"content">
824 <pre><tt>$ echo
"* text=auto" >>.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
829 $ git add .gitattributes
830 $ git commit -m
"Introduce end-of-line normalization"</tt></pre>
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>
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>
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
…</p></div>
851 <div class=
"ulist"><ul>
854 <em>git add
</em> itself does not touch the files in the work tree, the
855 next checkout would, so the safety triggers;
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;
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.
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>
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"]
915 smudge = cat
</tt></pre>
917 <div class=
"paragraph"><p>For best results,
<tt>clean
</tt> should not alter its output further if it is
918 run twice (
"clean→clean" should be equivalent to
"clean"), and
919 multiple
<tt>smudge
</tt> commands should not alter
<tt>clean
</tt>'s output
920 (
"smudge→smudge→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>
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
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→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>
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.
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).
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>.
1000 <dt class=
"hdlist1">
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
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
…</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>
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>
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>
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>
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>
1069 <tt>bibtex
</tt> suitable for files with BibTeX coded references.
1074 <tt>cpp
</tt> suitable for source code in the C and C++ languages.
1079 <tt>csharp
</tt> suitable for source code in the C# language.
1084 <tt>fortran
</tt> suitable for source code in the Fortran language.
1089 <tt>html
</tt> suitable for HTML/XHTML documents.
1094 <tt>java
</tt> suitable for source code in the Java language.
1099 <tt>objc
</tt> suitable for source code in the Objective-C language.
1104 <tt>pascal
</tt> suitable for source code in the Pascal/Delphi language.
1109 <tt>perl
</tt> suitable for source code in the Perl language.
1114 <tt>php
</tt> suitable for source code in the PHP language.
1119 <tt>python
</tt> suitable for source code in the Python language.
1124 <tt>ruby
</tt> suitable for source code in the Ruby language.
1129 <tt>tex
</tt> suitable for source code for LaTeX documents.
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>
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>
1168 <div class=
"admonitionblock">
1171 <div class=
"title">Note
</div>
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>
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
’s
1190 config. For example:
</p></div>
1191 <div class=
"listingblock">
1192 <div class=
"content">
1193 <pre><tt>[diff
"jpg"]
1195 cachetextconv = true
</tt></pre>
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">
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,
1229 Git diff features. By performing only the transformation step
1230 yourself, you can still utilize many of git
’s diff features,
1231 including colorization, word-diff, and combined diffs for merges.
1236 Caching. Textconv caching can speed up repeated diffs, such as those
1237 you might trigger by running
<tt>git log -p
</tt>.
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>
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"]
1266 binary = true
</tt></pre>
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">
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.
1284 <dt class=
"hdlist1">
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.
1295 <dt class=
"hdlist1">
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.
1307 <dt class=
"hdlist1">
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".
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">
1329 Usual
3-way file level merge for text files. Conflicted
1330 regions are marked with conflict markers
<tt><<<<<<<</tt>,
1331 <tt>=======
</tt> and
<tt>>>>>>>></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>
1337 <dt class=
"hdlist1">
1342 Keep the version from your branch in the work tree, but
1343 leave the path in the conflicted state for the user to
1347 <dt class=
"hdlist1">
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.
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
…</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>
1374 <div class=
"paragraph"><p>The
<tt>merge.*.name
</tt> variable gives the driver a human-readable
1376 <div class=
"paragraph"><p>The
‘merge.*.driver` variable
’s value is used to construct a
1377 command to run to merge ancestor
’s version (
<tt>%O
</tt>), current
1378 version (
<tt>%A
</tt>) and the other branches
’ 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>
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">
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.
1421 <dt class=
"hdlist1">
1426 Do not notice anything as error.
1429 <dt class=
"hdlist1">
1434 Use the value of the
<tt>core.whitespace
</tt> configuration variable to
1435 decide what to notice as error.
1438 <dt class=
"hdlist1">
1443 Specify a comma separate list of common whitespace problems to
1444 notice in the same format as the
<tt>core.whitespace
</tt> configuration
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
’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>
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>
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>
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"
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>
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)
1522 (in t/.gitattributes)
1525 *.c frotz
</tt></pre>
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">
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>
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.
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.
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
1562 merge set to string value
"filfre"
1563 frotz unspecified
</tt></pre>
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>
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>
1575 <div id=
"footnotes"><hr /></div>
1577 <div id=
"footer-text">
1578 Last updated
2011-
09-
21 23:
01:
14 PDT