Autogenerated HTML docs for v2.47.0-318-g04eaf
[git-htmldocs.git] / gitattributes.html
blobc7bb2afb7ef37dde1e95f4f7916c614777872a88
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3 <head>
4 <meta charset="UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
6 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7 <meta name="generator" content="Asciidoctor 2.0.20"/>
8 <title>gitattributes(5)</title>
9 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"/>
10 <style>
11 /*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
12 /* Uncomment the following line when using as a custom stylesheet */
13 /* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
14 html{font-family:sans-serif;-webkit-text-size-adjust:100%}
15 a{background:none}
16 a:focus{outline:thin dotted}
17 a:active,a:hover{outline:0}
18 h1{font-size:2em;margin:.67em 0}
19 b,strong{font-weight:bold}
20 abbr{font-size:.9em}
21 abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
22 dfn{font-style:italic}
23 hr{height:0}
24 mark{background:#ff0;color:#000}
25 code,kbd,pre,samp{font-family:monospace;font-size:1em}
26 pre{white-space:pre-wrap}
27 q{quotes:"\201C" "\201D" "\2018" "\2019"}
28 small{font-size:80%}
29 sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
30 sup{top:-.5em}
31 sub{bottom:-.25em}
32 img{border:0}
33 svg:not(:root){overflow:hidden}
34 figure{margin:0}
35 audio,video{display:inline-block}
36 audio:not([controls]){display:none;height:0}
37 fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
38 legend{border:0;padding:0}
39 button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
40 button,input{line-height:normal}
41 button,select{text-transform:none}
42 button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
43 button[disabled],html input[disabled]{cursor:default}
44 input[type=checkbox],input[type=radio]{padding:0}
45 button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
46 textarea{overflow:auto;vertical-align:top}
47 table{border-collapse:collapse;border-spacing:0}
48 *,::before,::after{box-sizing:border-box}
49 html,body{font-size:100%}
50 body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
51 a:hover{cursor:pointer}
52 img,object,embed{max-width:100%;height:auto}
53 object,embed{height:100%}
54 img{-ms-interpolation-mode:bicubic}
55 .left{float:left!important}
56 .right{float:right!important}
57 .text-left{text-align:left!important}
58 .text-right{text-align:right!important}
59 .text-center{text-align:center!important}
60 .text-justify{text-align:justify!important}
61 .hide{display:none}
62 img,object,svg{display:inline-block;vertical-align:middle}
63 textarea{height:auto;min-height:50px}
64 select{width:100%}
65 .subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
66 div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
67 a{color:#2156a5;text-decoration:underline;line-height:inherit}
68 a:hover,a:focus{color:#1d4b8f}
69 a img{border:0}
70 p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
71 p aside{font-size:.875em;line-height:1.35;font-style:italic}
72 h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
73 h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
74 h1{font-size:2.125em}
75 h2{font-size:1.6875em}
76 h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
77 h4,h5{font-size:1.125em}
78 h6{font-size:1em}
79 hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
80 em,i{font-style:italic;line-height:inherit}
81 strong,b{font-weight:bold;line-height:inherit}
82 small{font-size:60%;line-height:inherit}
83 code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
84 ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
85 ul,ol{margin-left:1.5em}
86 ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
87 ul.circle{list-style-type:circle}
88 ul.disc{list-style-type:disc}
89 ul.square{list-style-type:square}
90 ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit}
91 ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
92 dl dt{margin-bottom:.3125em;font-weight:bold}
93 dl dd{margin-bottom:1.25em}
94 blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
95 blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
96 @media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
97 h1{font-size:2.75em}
98 h2{font-size:2.3125em}
99 h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
100 h4{font-size:1.4375em}}
101 table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
102 table thead,table tfoot{background:#f7f8f7}
103 table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
104 table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
105 table tr.even,table tr.alt{background:#f8f8f7}
106 table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
107 h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
108 h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
109 .center{margin-left:auto;margin-right:auto}
110 .stretch{width:100%}
111 .clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
112 .clearfix::after,.float-group::after{clear:both}
113 :not(pre).nobreak{word-wrap:normal}
114 :not(pre).nowrap{white-space:nowrap}
115 :not(pre).pre-wrap{white-space:pre-wrap}
116 :not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
117 pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
118 pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
119 pre>code{display:block}
120 pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
121 em em{font-style:normal}
122 strong strong{font-weight:400}
123 .keyseq{color:rgba(51,51,51,.8)}
124 kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
125 .keyseq kbd:first-child{margin-left:0}
126 .keyseq kbd:last-child{margin-right:0}
127 .menuseq,.menuref{color:#000}
128 .menuseq b:not(.caret),.menuref{font-weight:inherit}
129 .menuseq{word-spacing:-.02em}
130 .menuseq b.caret{font-size:1.25em;line-height:.8}
131 .menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
132 b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
133 b.button::before{content:"[";padding:0 3px 0 2px}
134 b.button::after{content:"]";padding:0 2px 0 3px}
135 p a>code:hover{color:rgba(0,0,0,.9)}
136 #header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
137 #header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
138 #header::after,#content::after,#footnotes::after,#footer::after{clear:both}
139 #content{margin-top:1.25em}
140 #content::before{content:none}
141 #header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
142 #header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
143 #header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
144 #header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
145 #header .details span:first-child{margin-left:-.125em}
146 #header .details span.email a{color:rgba(0,0,0,.85)}
147 #header .details br{display:none}
148 #header .details br+span::before{content:"\00a0\2013\00a0"}
149 #header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
150 #header .details br+span#revremark::before{content:"\00a0|\00a0"}
151 #header #revnumber{text-transform:capitalize}
152 #header #revnumber::after{content:"\00a0"}
153 #content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
154 #toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
155 #toc>ul{margin-left:.125em}
156 #toc ul.sectlevel0>li>a{font-style:italic}
157 #toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
158 #toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
159 #toc li{line-height:1.3334;margin-top:.3334em}
160 #toc a{text-decoration:none}
161 #toc a:active{text-decoration:underline}
162 #toctitle{color:#7a2518;font-size:1.2em}
163 @media screen and (min-width:768px){#toctitle{font-size:1.375em}
164 body.toc2{padding-left:15em;padding-right:0}
165 #toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
166 #toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
167 #toc.toc2>ul{font-size:.9em;margin-bottom:0}
168 #toc.toc2 ul ul{margin-left:0;padding-left:1em}
169 #toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
170 body.toc2.toc-right{padding-left:0;padding-right:15em}
171 body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
172 @media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
173 #toc.toc2{width:20em}
174 #toc.toc2 #toctitle{font-size:1.375em}
175 #toc.toc2>ul{font-size:.95em}
176 #toc.toc2 ul ul{padding-left:1.25em}
177 body.toc2.toc-right{padding-left:0;padding-right:20em}}
178 #content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
179 #content #toc>:first-child{margin-top:0}
180 #content #toc>:last-child{margin-bottom:0}
181 #footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
182 #footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
183 #content{margin-bottom:.625em}
184 .sect1{padding-bottom:.625em}
185 @media screen and (min-width:768px){#content{margin-bottom:1.25em}
186 .sect1{padding-bottom:1.25em}}
187 .sect1:last-child{padding-bottom:0}
188 .sect1+.sect1{border-top:1px solid #e7e7e9}
189 #content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
190 #content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
191 #content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
192 #content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
193 #content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
194 details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
195 details{margin-left:1.25rem}
196 details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
197 details>summary::-webkit-details-marker{display:none}
198 details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
199 details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
200 details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
201 .admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
202 table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
203 .paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
204 .admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
205 .admonitionblock>table td.icon{text-align:center;width:80px}
206 .admonitionblock>table td.icon img{max-width:none}
207 .admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
208 .admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
209 .admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
210 .exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
211 .sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
212 .sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
213 .exampleblock>.content>:first-child,.sidebarblock>.content>:first-child{margin-top:0}
214 .exampleblock>.content>:last-child,.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
215 .literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
216 @media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
217 @media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
218 .literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
219 .literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
220 .listingblock>.content{position:relative}
221 .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
222 .listingblock:hover code[data-lang]::before{display:block}
223 .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
224 .listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
225 .listingblock pre.highlightjs{padding:0}
226 .listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
227 .listingblock pre.prettyprint{border-width:0}
228 .prettyprint{background:#f7f7f8}
229 pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
230 pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
231 pre.prettyprint li code[data-lang]::before{opacity:1}
232 pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
233 table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
234 table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
235 table.linenotable td.code{padding-left:.75em}
236 table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
237 pre.pygments span.linenos{display:inline-block;margin-right:.75em}
238 .quoteblock{margin:0 1em 1.25em 1.5em;display:table}
239 .quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
240 .quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
241 .quoteblock blockquote{margin:0;padding:0;border:0}
242 .quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
243 .quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
244 .quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
245 .verseblock{margin:0 1em 1.25em}
246 .verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
247 .verseblock pre strong{font-weight:400}
248 .verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
249 .quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
250 .quoteblock .attribution br,.verseblock .attribution br{display:none}
251 .quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
252 .quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
253 .quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
254 .quoteblock.abstract{margin:0 1em 1.25em;display:block}
255 .quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
256 .quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
257 .quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
258 .quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
259 .quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
260 p.tableblock:last-child{margin-bottom:0}
261 td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
262 td.tableblock>.content>:last-child{margin-bottom:-1.25em}
263 table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
264 table.grid-all>*>tr>*{border-width:1px}
265 table.grid-cols>*>tr>*{border-width:0 1px}
266 table.grid-rows>*>tr>*{border-width:1px 0}
267 table.frame-all{border-width:1px}
268 table.frame-ends{border-width:1px 0}
269 table.frame-sides{border-width:0 1px}
270 table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
271 table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
272 table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
273 table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
274 table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
275 th.halign-left,td.halign-left{text-align:left}
276 th.halign-right,td.halign-right{text-align:right}
277 th.halign-center,td.halign-center{text-align:center}
278 th.valign-top,td.valign-top{vertical-align:top}
279 th.valign-bottom,td.valign-bottom{vertical-align:bottom}
280 th.valign-middle,td.valign-middle{vertical-align:middle}
281 table thead th,table tfoot th{font-weight:bold}
282 tbody tr th{background:#f7f8f7}
283 tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
284 p.tableblock>code:only-child{background:none;padding:0}
285 p.tableblock{font-size:1em}
286 ol{margin-left:1.75em}
287 ul li ol{margin-left:1.5em}
288 dl dd{margin-left:1.125em}
289 dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
290 li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
291 ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
292 ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
293 ul.unstyled,ol.unstyled{margin-left:0}
294 li>p:empty:only-child::before{content:"";display:inline-block}
295 ul.checklist>li>p:first-child{margin-left:-1em}
296 ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
297 ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
298 ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
299 ul.inline>li{margin-left:1.25em}
300 .unstyled dl dt{font-weight:400;font-style:normal}
301 ol.arabic{list-style-type:decimal}
302 ol.decimal{list-style-type:decimal-leading-zero}
303 ol.loweralpha{list-style-type:lower-alpha}
304 ol.upperalpha{list-style-type:upper-alpha}
305 ol.lowerroman{list-style-type:lower-roman}
306 ol.upperroman{list-style-type:upper-roman}
307 ol.lowergreek{list-style-type:lower-greek}
308 .hdlist>table,.colist>table{border:0;background:none}
309 .hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
310 td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
311 td.hdlist1{font-weight:bold;padding-bottom:1.25em}
312 td.hdlist2{word-wrap:anywhere}
313 .literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
314 .colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
315 .colist td:not([class]):first-child img{max-width:none}
316 .colist td:not([class]):last-child{padding:.25em 0}
317 .thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
318 .imageblock.left{margin:.25em .625em 1.25em 0}
319 .imageblock.right{margin:.25em 0 1.25em .625em}
320 .imageblock>.title{margin-bottom:0}
321 .imageblock.thumb,.imageblock.th{border-width:6px}
322 .imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
323 .image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
324 .image.left{margin-right:.625em}
325 .image.right{margin-left:.625em}
326 a.image{text-decoration:none;display:inline-block}
327 a.image object{pointer-events:none}
328 sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
329 sup.footnote a,sup.footnoteref a{text-decoration:none}
330 sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
331 #footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
332 #footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
333 #footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
334 #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
335 #footnotes .footnote:last-of-type{margin-bottom:0}
336 #content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
337 div.unbreakable{page-break-inside:avoid}
338 .big{font-size:larger}
339 .small{font-size:smaller}
340 .underline{text-decoration:underline}
341 .overline{text-decoration:overline}
342 .line-through{text-decoration:line-through}
343 .aqua{color:#00bfbf}
344 .aqua-background{background:#00fafa}
345 .black{color:#000}
346 .black-background{background:#000}
347 .blue{color:#0000bf}
348 .blue-background{background:#0000fa}
349 .fuchsia{color:#bf00bf}
350 .fuchsia-background{background:#fa00fa}
351 .gray{color:#606060}
352 .gray-background{background:#7d7d7d}
353 .green{color:#006000}
354 .green-background{background:#007d00}
355 .lime{color:#00bf00}
356 .lime-background{background:#00fa00}
357 .maroon{color:#600000}
358 .maroon-background{background:#7d0000}
359 .navy{color:#000060}
360 .navy-background{background:#00007d}
361 .olive{color:#606000}
362 .olive-background{background:#7d7d00}
363 .purple{color:#600060}
364 .purple-background{background:#7d007d}
365 .red{color:#bf0000}
366 .red-background{background:#fa0000}
367 .silver{color:#909090}
368 .silver-background{background:#bcbcbc}
369 .teal{color:#006060}
370 .teal-background{background:#007d7d}
371 .white{color:#bfbfbf}
372 .white-background{background:#fafafa}
373 .yellow{color:#bfbf00}
374 .yellow-background{background:#fafa00}
375 span.icon>.fa{cursor:default}
376 a span.icon>.fa{cursor:inherit}
377 .admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
378 .admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
379 .admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
380 .admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
381 .admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
382 .admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
383 .conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
384 .conum[data-value] *{color:#fff!important}
385 .conum[data-value]+b{display:none}
386 .conum[data-value]::after{content:attr(data-value)}
387 pre .conum[data-value]{position:relative;top:-.125em}
388 b.conum *{color:inherit!important}
389 .conum:not([data-value]):empty{display:none}
390 dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
391 h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
392 p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
393 p,blockquote,dt,td.content,td.hdlist1,span.alt,summary{font-size:1.0625rem}
394 p{margin-bottom:1.25rem}
395 .sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
396 .exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
397 .print-only{display:none!important}
398 @page{margin:1.25cm .75cm}
399 @media print{*{box-shadow:none!important;text-shadow:none!important}
400 html{font-size:80%}
401 a{color:inherit!important;text-decoration:underline!important}
402 a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
403 a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
404 abbr[title]{border-bottom:1px dotted}
405 abbr[title]::after{content:" (" attr(title) ")"}
406 pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
407 thead{display:table-header-group}
408 svg{max-width:100%}
409 p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
410 h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
411 #header,#content,#footnotes,#footer{max-width:none}
412 #toc,.sidebarblock,.exampleblock>.content{background:none!important}
413 #toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
414 body.book #header{text-align:center}
415 body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
416 body.book #header .details{border:0!important;display:block;padding:0!important}
417 body.book #header .details span:first-child{margin-left:0!important}
418 body.book #header .details br{display:block}
419 body.book #header .details br+span::before{content:none!important}
420 body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
421 body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
422 .listingblock code[data-lang]::before{display:block}
423 #footer{padding:0 .9375em}
424 .hide-on-print{display:none!important}
425 .print-only{display:block!important}
426 .hide-for-print{display:none!important}
427 .show-for-print{display:inherit!important}}
428 @media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
429 .sect1{padding:0!important}
430 .sect1+.sect1{border:0}
431 #footer{background:none}
432 #footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
433 @media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
434 </style>
435 <style>
436 pre>code {
437 display: inline;
439 </style>
440 </head>
441 <body class="manpage">
442 <div id="header">
443 <h1>gitattributes(5) Manual Page</h1>
444 <h2 id="_name">NAME</h2>
445 <div class="sectionbody">
446 <p>gitattributes - Defining attributes per path</p>
447 </div>
448 </div>
449 <div id="content">
450 <div class="sect1">
451 <h2 id="_synopsis">SYNOPSIS</h2>
452 <div class="sectionbody">
453 <div class="paragraph">
454 <p>$GIT_DIR/info/attributes, .gitattributes</p>
455 </div>
456 </div>
457 </div>
458 <div class="sect1">
459 <h2 id="_description">DESCRIPTION</h2>
460 <div class="sectionbody">
461 <div class="paragraph">
462 <p>A <code>gitattributes</code> file is a simple text file that gives
463 <code>attributes</code> to pathnames.</p>
464 </div>
465 <div class="paragraph">
466 <p>Each line in <code>gitattributes</code> file is of form:</p>
467 </div>
468 <div class="literalblock">
469 <div class="content">
470 <pre>pattern attr1 attr2 ...</pre>
471 </div>
472 </div>
473 <div class="paragraph">
474 <p>That is, a pattern followed by an attributes list,
475 separated by whitespaces. Leading and trailing whitespaces are
476 ignored. Lines that begin with <em>#</em> are ignored. Patterns
477 that begin with a double quote are quoted in C style.
478 When the pattern matches the path in question, the attributes
479 listed on the line are given to the path.</p>
480 </div>
481 <div class="paragraph">
482 <p>Each attribute can be in one of these states for a given path:</p>
483 </div>
484 <div class="dlist">
485 <dl>
486 <dt class="hdlist1">Set</dt>
487 <dd>
488 <p>The path has the attribute with special value "true";
489 this is specified by listing only the name of the
490 attribute in the attribute list.</p>
491 </dd>
492 <dt class="hdlist1">Unset</dt>
493 <dd>
494 <p>The path has the attribute with special value "false";
495 this is specified by listing the name of the attribute
496 prefixed with a dash <code>-</code> in the attribute list.</p>
497 </dd>
498 <dt class="hdlist1">Set to a value</dt>
499 <dd>
500 <p>The path has the attribute with specified string value;
501 this is specified by listing the name of the attribute
502 followed by an equal sign <code>=</code> and its value in the
503 attribute list.</p>
504 </dd>
505 <dt class="hdlist1">Unspecified</dt>
506 <dd>
507 <p>No pattern matches the path, and nothing says if
508 the path has or does not have the attribute, the
509 attribute for the path is said to be Unspecified.</p>
510 </dd>
511 </dl>
512 </div>
513 <div class="paragraph">
514 <p>When more than one pattern matches the path, a later line
515 overrides an earlier line. This overriding is done per
516 attribute.</p>
517 </div>
518 <div class="paragraph">
519 <p>The rules by which the pattern matches paths are the same as in
520 .<code>gitignore</code> files (see <a href="gitignore.html">gitignore(5)</a>), with a few exceptions:</p>
521 </div>
522 <div class="ulist">
523 <ul>
524 <li>
525 <p>negative patterns are forbidden</p>
526 </li>
527 <li>
528 <p>patterns that match a directory do not recursively match paths
529 inside that directory (so using the trailing-slash <code>path/</code> syntax is
530 pointless in an attributes file; use <code>path/</code>** instead)</p>
531 </li>
532 </ul>
533 </div>
534 <div class="paragraph">
535 <p>When deciding what attributes are assigned to a path, Git
536 consults <code>$GIT_DIR/info/attributes</code> file (which has the highest
537 precedence), .<code>gitattributes</code> file in the same directory as the
538 path in question, and its parent directories up to the toplevel of the
539 work tree (the further the directory that contains .<code>gitattributes</code>
540 is from the path in question, the lower its precedence). Finally
541 global and system-wide files are considered (they have the lowest
542 precedence).</p>
543 </div>
544 <div class="paragraph">
545 <p>When the .<code>gitattributes</code> file is missing from the work tree, the
546 path in the index is used as a fall-back. During checkout process,
547 .<code>gitattributes</code> in the index is used and then the file in the
548 working tree is used as a fall-back.</p>
549 </div>
550 <div class="paragraph">
551 <p>If you wish to affect only a single repository (i.e., to assign
552 attributes to files that are particular to
553 one user&#8217;s workflow for that repository), then
554 attributes should be placed in the <code>$GIT_DIR/info/attributes</code> file.
555 Attributes which should be version-controlled and distributed to other
556 repositories (i.e., attributes of interest to all users) should go into
557 .<code>gitattributes</code> files. Attributes that should affect all repositories
558 for a single user should be placed in a file specified by the
559 <code>core.attributesFile</code> configuration option (see <a href="git-config.html">git-config(1)</a>).
560 Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME
561 is either not set or empty, $HOME/.config/git/attributes is used instead.
562 Attributes for all users on a system should be placed in the
563 <code>$</code>(<code>prefix</code>)<code>/etc/gitattributes</code> file.</p>
564 </div>
565 <div class="paragraph">
566 <p>Sometimes you would need to override a setting of an attribute
567 for a path to <code>Unspecified</code> state. This can be done by listing
568 the name of the attribute prefixed with an exclamation point !.</p>
569 </div>
570 </div>
571 </div>
572 <div class="sect1">
573 <h2 id="_reserved_builtin_attributes">RESERVED BUILTIN_* ATTRIBUTES</h2>
574 <div class="sectionbody">
575 <div class="paragraph">
576 <p>builtin_* is a reserved namespace for builtin attribute values. Any
577 user defined attributes under this namespace will be ignored and
578 trigger a warning.</p>
579 </div>
580 <div class="sect2">
581 <h3 id="_builtin_objectmode"><code>builtin_objectmode</code></h3>
582 <div class="paragraph">
583 <p>This attribute is for filtering files by their file bit modes (40000,
584 120000, 160000, 100755, 100644). e.g. <em>:(attr:builtin_objectmode=160000)</em>.
585 You may also check these values with <code>git</code> <code>check-attr</code> <code>builtin_objectmode</code> <code>--</code> <em>&lt;file&gt;</em>.
586 If the object is not in the index <code>git</code> <code>check-attr</code> <code>--cached</code> will return unspecified.</p>
587 </div>
588 </div>
589 </div>
590 </div>
591 <div class="sect1">
592 <h2 id="_effects">EFFECTS</h2>
593 <div class="sectionbody">
594 <div class="paragraph">
595 <p>Certain operations by Git can be influenced by assigning
596 particular attributes to a path. Currently, the following
597 operations are attributes-aware.</p>
598 </div>
599 <div class="sect2">
600 <h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3>
601 <div class="paragraph">
602 <p>These attributes affect how the contents stored in the
603 repository are copied to the working tree files when commands
604 such as <em>git switch</em>, <em>git checkout</em> and <em>git merge</em> run.
605 They also affect how
606 Git stores the contents you prepare in the working tree in the
607 repository upon <em>git add</em> and <em>git commit</em>.</p>
608 </div>
609 <div class="sect3">
610 <h4 id="_text"><code>text</code></h4>
611 <div class="paragraph">
612 <p>This attribute marks the path as a text file, which enables end-of-line
613 conversion: When a matching file is added to the index, the file&#8217;s line
614 endings are normalized to LF in the index. Conversely, when the file is
615 copied from the index to the working directory, its line endings may be
616 converted from LF to CRLF depending on the <code>eol</code> attribute, the Git
617 config, and the platform (see explanation of <code>eol</code> below).</p>
618 </div>
619 <div class="dlist">
620 <dl>
621 <dt class="hdlist1">Set</dt>
622 <dd>
623 <p>Setting the <code>text</code> attribute on a path enables end-of-line
624 conversion on checkin and checkout as described above. Line endings
625 are normalized to LF in the index every time the file is checked in,
626 even if the file was previously added to Git with CRLF line endings.</p>
627 </dd>
628 <dt class="hdlist1">Unset</dt>
629 <dd>
630 <p>Unsetting the <code>text</code> attribute on a path tells Git not to
631 attempt any end-of-line conversion upon checkin or checkout.</p>
632 </dd>
633 <dt class="hdlist1">Set to string value "auto"</dt>
634 <dd>
635 <p>When <code>text</code> is set to "auto", Git decides by itself whether the file
636 is text or binary. If it is text and the file was not already in
637 Git with CRLF endings, line endings are converted on checkin and
638 checkout as described above. Otherwise, no conversion is done on
639 checkin or checkout.</p>
640 </dd>
641 <dt class="hdlist1">Unspecified</dt>
642 <dd>
643 <p>If the <code>text</code> attribute is unspecified, Git uses the
644 <code>core.autocrlf</code> configuration variable to determine if the
645 file should be converted.</p>
646 </dd>
647 </dl>
648 </div>
649 <div class="paragraph">
650 <p>Any other value causes Git to act as if <code>text</code> has been left
651 unspecified.</p>
652 </div>
653 </div>
654 <div class="sect3">
655 <h4 id="_eol"><code>eol</code></h4>
656 <div class="paragraph">
657 <p>This attribute marks a path to use a specific line-ending style in the
658 working tree when it is checked out. It has effect only if <code>text</code> or
659 <code>text=auto</code> is set (see above), but specifying <code>eol</code> automatically sets
660 <code>text</code> if <code>text</code> was left unspecified.</p>
661 </div>
662 <div class="dlist">
663 <dl>
664 <dt class="hdlist1">Set to string value "crlf"</dt>
665 <dd>
666 <p>This setting converts the file&#8217;s line endings in the working
667 directory to CRLF when the file is checked out.</p>
668 </dd>
669 <dt class="hdlist1">Set to string value "lf"</dt>
670 <dd>
671 <p>This setting uses the same line endings in the working directory as
672 in the index when the file is checked out.</p>
673 </dd>
674 <dt class="hdlist1">Unspecified</dt>
675 <dd>
676 <p>If the <code>eol</code> attribute is unspecified for a file, its line endings
677 in the working directory are determined by the <code>core.autocrlf</code> or
678 <code>core.eol</code> configuration variable (see the definitions of those
679 options in <a href="git-config.html">git-config(1)</a>). If <code>text</code> is set but neither of
680 those variables is, the default is <code>eol=crlf</code> on Windows and
681 <code>eol=lf</code> on all other platforms.</p>
682 </dd>
683 </dl>
684 </div>
685 </div>
686 <div class="sect3">
687 <h4 id="_backwards_compatibility_with_crlf_attribute">Backwards compatibility with <code>crlf</code> attribute</h4>
688 <div class="paragraph">
689 <p>For backwards compatibility, the <code>crlf</code> attribute is interpreted as
690 follows:</p>
691 </div>
692 <div class="listingblock">
693 <div class="content">
694 <pre>crlf text
695 -crlf -text
696 crlf=input eol=lf</pre>
697 </div>
698 </div>
699 </div>
700 <div class="sect3">
701 <h4 id="_end_of_line_conversion">End-of-line conversion</h4>
702 <div class="paragraph">
703 <p>While Git normally leaves file contents alone, it can be configured to
704 normalize line endings to LF in the repository and, optionally, to
705 convert them to CRLF when files are checked out.</p>
706 </div>
707 <div class="paragraph">
708 <p>If you simply want to have CRLF line endings in your working directory
709 regardless of the repository you are working with, you can set the
710 config variable "core.autocrlf" without using any attributes.</p>
711 </div>
712 <div class="listingblock">
713 <div class="content">
714 <pre>[core]
715 autocrlf = true</pre>
716 </div>
717 </div>
718 <div class="paragraph">
719 <p>This does not force normalization of text files, but does ensure
720 that text files that you introduce to the repository have their line
721 endings normalized to LF when they are added, and that files that are
722 already normalized in the repository stay normalized.</p>
723 </div>
724 <div class="paragraph">
725 <p>If you want to ensure that text files that any contributor introduces to
726 the repository have their line endings normalized, you can set the
727 <code>text</code> attribute to "auto" for <em>all</em> files.</p>
728 </div>
729 <div class="listingblock">
730 <div class="content">
731 <pre>* text=auto</pre>
732 </div>
733 </div>
734 <div class="paragraph">
735 <p>The attributes allow a fine-grained control, how the line endings
736 are converted.
737 Here is an example that will make Git normalize .txt, .vcproj and .sh
738 files, ensure that .vcproj files have CRLF and .sh files have LF in
739 the working directory, and prevent .jpg files from being normalized
740 regardless of their content.</p>
741 </div>
742 <div class="listingblock">
743 <div class="content">
744 <pre>* text=auto
745 *.txt text
746 *.vcproj text eol=crlf
747 *.sh text eol=lf
748 *.jpg -text</pre>
749 </div>
750 </div>
751 <div class="admonitionblock note">
752 <table>
753 <tr>
754 <td class="icon">
755 <div class="title">Note</div>
756 </td>
757 <td class="content">
758 When <code>text=auto</code> conversion is enabled in a cross-platform
759 project using push and pull to a central repository the text files
760 containing CRLFs should be normalized.
761 </td>
762 </tr>
763 </table>
764 </div>
765 <div class="paragraph">
766 <p>From a clean working directory:</p>
767 </div>
768 <div class="listingblock">
769 <div class="content">
770 <pre>$ echo "* text=auto" &gt;.gitattributes
771 $ git add --renormalize .
772 $ git status # Show files that will be normalized
773 $ git commit -m "Introduce end-of-line normalization"</pre>
774 </div>
775 </div>
776 <div class="paragraph">
777 <p>If any files that should not be normalized show up in <em>git status</em>,
778 unset their <code>text</code> attribute before running <em>git add -u</em>.</p>
779 </div>
780 <div class="listingblock">
781 <div class="content">
782 <pre>manual.pdf -text</pre>
783 </div>
784 </div>
785 <div class="paragraph">
786 <p>Conversely, text files that Git does not detect can have normalization
787 enabled manually.</p>
788 </div>
789 <div class="listingblock">
790 <div class="content">
791 <pre>weirdchars.txt text</pre>
792 </div>
793 </div>
794 <div class="paragraph">
795 <p>If <code>core.safecrlf</code> is set to "true" or "warn", Git verifies if
796 the conversion is reversible for the current setting of
797 <code>core.autocrlf</code>. For "true", Git rejects irreversible
798 conversions; for "warn", Git only prints a warning but accepts
799 an irreversible conversion. The safety triggers to prevent such
800 a conversion done to the files in the work tree, but there are a
801 few exceptions. Even though&#8230;&#8203;</p>
802 </div>
803 <div class="ulist">
804 <ul>
805 <li>
806 <p><em>git add</em> itself does not touch the files in the work tree, the
807 next checkout would, so the safety triggers;</p>
808 </li>
809 <li>
810 <p><em>git apply</em> to update a text file with a patch does touch the files
811 in the work tree, but the operation is about text files and CRLF
812 conversion is about fixing the line ending inconsistencies, so the
813 safety does not trigger;</p>
814 </li>
815 <li>
816 <p><em>git diff</em> itself does not touch the files in the work tree, it is
817 often run to inspect the changes you intend to next <em>git add</em>. To
818 catch potential problems early, safety triggers.</p>
819 </li>
820 </ul>
821 </div>
822 </div>
823 <div class="sect3">
824 <h4 id="_working_tree_encoding"><code>working-tree-encoding</code></h4>
825 <div class="paragraph">
826 <p>Git recognizes files encoded in ASCII or one of its supersets (e.g.
827 UTF-8, ISO-8859-1, &#8230;&#8203;) as text files. Files encoded in certain other
828 encodings (e.g. UTF-16) are interpreted as binary and consequently
829 built-in Git text processing tools (e.g. <em>git diff</em>) as well as most Git
830 web front ends do not visualize the contents of these files by default.</p>
831 </div>
832 <div class="paragraph">
833 <p>In these cases you can tell Git the encoding of a file in the working
834 directory with the <code>working-tree-encoding</code> attribute. If a file with this
835 attribute is added to Git, then Git re-encodes the content from the
836 specified encoding to UTF-8. Finally, Git stores the UTF-8 encoded
837 content in its internal data structure (called "the index"). On checkout
838 the content is re-encoded back to the specified encoding.</p>
839 </div>
840 <div class="paragraph">
841 <p>Please note that using the <code>working-tree-encoding</code> attribute may have a
842 number of pitfalls:</p>
843 </div>
844 <div class="ulist">
845 <ul>
846 <li>
847 <p>Alternative Git implementations (e.g. JGit or libgit2) and older Git
848 versions (as of March 2018) do not support the <code>working-tree-encoding</code>
849 attribute. If you decide to use the <code>working-tree-encoding</code> attribute
850 in your repository, then it is strongly recommended to ensure that all
851 clients working with the repository support it.</p>
852 <div class="paragraph">
853 <p>For example, Microsoft Visual Studio resources files (*.<code>rc</code>) or
854 PowerShell script files (*.<code>ps1</code>) are sometimes encoded in UTF-16.
855 If you declare *.<code>ps1</code> as files as UTF-16 and you add <code>foo.ps1</code> with
856 a <code>working-tree-encoding</code> enabled Git client, then <code>foo.ps1</code> will be
857 stored as UTF-8 internally. A client without <code>working-tree-encoding</code>
858 support will checkout <code>foo.ps1</code> as UTF-8 encoded file. This will
859 typically cause trouble for the users of this file.</p>
860 </div>
861 <div class="paragraph">
862 <p>If a Git client that does not support the <code>working-tree-encoding</code>
863 attribute adds a new file <code>bar.ps1</code>, then <code>bar.ps1</code> will be
864 stored "as-is" internally (in this example probably as UTF-16).
865 A client with <code>working-tree-encoding</code> support will interpret the
866 internal contents as UTF-8 and try to convert it to UTF-16 on checkout.
867 That operation will fail and cause an error.</p>
868 </div>
869 </li>
870 <li>
871 <p>Reencoding content to non-UTF encodings can cause errors as the
872 conversion might not be UTF-8 round trip safe. If you suspect your
873 encoding to not be round trip safe, then add it to
874 <code>core.checkRoundtripEncoding</code> to make Git check the round trip
875 encoding (see <a href="git-config.html">git-config(1)</a>). SHIFT-JIS (Japanese character
876 set) is known to have round trip issues with UTF-8 and is checked by
877 default.</p>
878 </li>
879 <li>
880 <p>Reencoding content requires resources that might slow down certain
881 Git operations (e.g <em>git checkout</em> or <em>git add</em>).</p>
882 </li>
883 </ul>
884 </div>
885 <div class="paragraph">
886 <p>Use the <code>working-tree-encoding</code> attribute only if you cannot store a file
887 in UTF-8 encoding and if you want Git to be able to process the content
888 as text.</p>
889 </div>
890 <div class="paragraph">
891 <p>As an example, use the following attributes if your <em>*.ps1</em> files are
892 UTF-16 encoded with byte order mark (BOM) and you want Git to perform
893 automatic line ending conversion based on your platform.</p>
894 </div>
895 <div class="listingblock">
896 <div class="content">
897 <pre>*.ps1 text working-tree-encoding=UTF-16</pre>
898 </div>
899 </div>
900 <div class="paragraph">
901 <p>Use the following attributes if your <em>*.ps1</em> files are UTF-16 little
902 endian encoded without BOM and you want Git to use Windows line endings
903 in the working directory (use <code>UTF-16LE-BOM</code> instead of <code>UTF-16LE</code> if
904 you want UTF-16 little endian with BOM).
905 Please note, it is highly recommended to
906 explicitly define the line endings with <code>eol</code> if the <code>working-tree-encoding</code>
907 attribute is used to avoid ambiguity.</p>
908 </div>
909 <div class="listingblock">
910 <div class="content">
911 <pre>*.ps1 text working-tree-encoding=UTF-16LE eol=crlf</pre>
912 </div>
913 </div>
914 <div class="paragraph">
915 <p>You can get a list of all available encodings on your platform with the
916 following command:</p>
917 </div>
918 <div class="listingblock">
919 <div class="content">
920 <pre>iconv --list</pre>
921 </div>
922 </div>
923 <div class="paragraph">
924 <p>If you do not know the encoding of a file, then you can use the <code>file</code>
925 command to guess the encoding:</p>
926 </div>
927 <div class="listingblock">
928 <div class="content">
929 <pre>file foo.ps1</pre>
930 </div>
931 </div>
932 </div>
933 <div class="sect3">
934 <h4 id="_ident"><code>ident</code></h4>
935 <div class="paragraph">
936 <p>When the attribute <code>ident</code> is set for a path, Git replaces
937 <code>$Id$</code> in the blob object with <code>$Id:</code>, followed by the
938 40-character hexadecimal blob object name, followed by a dollar
939 sign <code>$</code> upon checkout. Any byte sequence that begins with
940 <code>$Id:</code> and ends with <code>$</code> in the worktree file is replaced
941 with <code>$Id$</code> upon check-in.</p>
942 </div>
943 </div>
944 <div class="sect3">
945 <h4 id="_filter"><code>filter</code></h4>
946 <div class="paragraph">
947 <p>A <code>filter</code> attribute can be set to a string value that names a
948 filter driver specified in the configuration.</p>
949 </div>
950 <div class="paragraph">
951 <p>A filter driver consists of a <code>clean</code> command and a <code>smudge</code>
952 command, either of which can be left unspecified. Upon
953 checkout, when the <code>smudge</code> command is specified, the command is
954 fed the blob object from its standard input, and its standard
955 output is used to update the worktree file. Similarly, the
956 <code>clean</code> command is used to convert the contents of worktree file
957 upon checkin. By default these commands process only a single
958 blob and terminate. If a long running <code>process</code> filter is used
959 in place of <code>clean</code> and/or <code>smudge</code> filters, then Git can process
960 all blobs with a single filter command invocation for the entire
961 life of a single Git command, for example <code>git</code> <code>add</code> <code>--all</code>. If a
962 long running <code>process</code> filter is configured then it always takes
963 precedence over a configured single blob filter. See section
964 below for the description of the protocol used to communicate with
965 a <code>process</code> filter.</p>
966 </div>
967 <div class="paragraph">
968 <p>One use of the content filtering is to massage the content into a shape
969 that is more convenient for the platform, filesystem, and the user to use.
970 For this mode of operation, the key phrase here is "more convenient" and
971 not "turning something unusable into usable". In other words, the intent
972 is that if someone unsets the filter driver definition, or does not have
973 the appropriate filter program, the project should still be usable.</p>
974 </div>
975 <div class="paragraph">
976 <p>Another use of the content filtering is to store the content that cannot
977 be directly used in the repository (e.g. a UUID that refers to the true
978 content stored outside Git, or an encrypted content) and turn it into a
979 usable form upon checkout (e.g. download the external content, or decrypt
980 the encrypted content).</p>
981 </div>
982 <div class="paragraph">
983 <p>These two filters behave differently, and by default, a filter is taken as
984 the former, massaging the contents into more convenient shape. A missing
985 filter driver definition in the config, or a filter driver that exits with
986 a non-zero status, is not an error but makes the filter a no-op passthru.</p>
987 </div>
988 <div class="paragraph">
989 <p>You can declare that a filter turns a content that by itself is unusable
990 into a usable content by setting the filter.&lt;driver&gt;.required configuration
991 variable to <code>true</code>.</p>
992 </div>
993 <div class="paragraph">
994 <p>Note: Whenever the clean filter is changed, the repo should be renormalized:
995 $ git add --renormalize .</p>
996 </div>
997 <div class="paragraph">
998 <p>For example, in .gitattributes, you would assign the <code>filter</code>
999 attribute for paths.</p>
1000 </div>
1001 <div class="listingblock">
1002 <div class="content">
1003 <pre>*.c filter=indent</pre>
1004 </div>
1005 </div>
1006 <div class="paragraph">
1007 <p>Then you would define a "filter.indent.clean" and "filter.indent.smudge"
1008 configuration in your .git/config to specify a pair of commands to
1009 modify the contents of C programs when the source files are checked
1010 in ("clean" is run) and checked out (no change is made because the
1011 command is "cat").</p>
1012 </div>
1013 <div class="listingblock">
1014 <div class="content">
1015 <pre>[filter "indent"]
1016 clean = indent
1017 smudge = cat</pre>
1018 </div>
1019 </div>
1020 <div class="paragraph">
1021 <p>For best results, <code>clean</code> should not alter its output further if it is
1022 run twice ("clean&#8594;clean" should be equivalent to "clean"), and
1023 multiple <code>smudge</code> commands should not alter <code>clean</code>'s output
1024 ("smudge&#8594;smudge&#8594;clean" should be equivalent to "clean"). See the
1025 section on merging below.</p>
1026 </div>
1027 <div class="paragraph">
1028 <p>The "indent" filter is well-behaved in this regard: it will not modify
1029 input that is already correctly indented. In this case, the lack of a
1030 smudge filter means that the clean filter <em>must</em> accept its own output
1031 without modifying it.</p>
1032 </div>
1033 <div class="paragraph">
1034 <p>If a filter <em>must</em> succeed in order to make the stored contents usable,
1035 you can declare that the filter is <code>required</code>, in the configuration:</p>
1036 </div>
1037 <div class="listingblock">
1038 <div class="content">
1039 <pre>[filter "crypt"]
1040 clean = openssl enc ...
1041 smudge = openssl enc -d ...
1042 required</pre>
1043 </div>
1044 </div>
1045 <div class="paragraph">
1046 <p>Sequence "%f" on the filter command line is replaced with the name of
1047 the file the filter is working on. A filter might use this in keyword
1048 substitution. For example:</p>
1049 </div>
1050 <div class="listingblock">
1051 <div class="content">
1052 <pre>[filter "p4"]
1053 clean = git-p4-filter --clean %f
1054 smudge = git-p4-filter --smudge %f</pre>
1055 </div>
1056 </div>
1057 <div class="paragraph">
1058 <p>Note that "%f" is the name of the path that is being worked on. Depending
1059 on the version that is being filtered, the corresponding file on disk may
1060 not exist, or may have different contents. So, smudge and clean commands
1061 should not try to access the file on disk, but only act as filters on the
1062 content provided to them on standard input.</p>
1063 </div>
1064 </div>
1065 <div class="sect3">
1066 <h4 id="_long_running_filter_process">Long Running Filter Process</h4>
1067 <div class="paragraph">
1068 <p>If the filter command (a string value) is defined via
1069 <code>filter.</code><em>&lt;driver&gt;</em><code>.process</code> then Git can process all blobs with a
1070 single filter invocation for the entire life of a single Git
1071 command. This is achieved by using the long-running process protocol
1072 (described in technical/long-running-process-protocol.txt).</p>
1073 </div>
1074 <div class="paragraph">
1075 <p>When Git encounters the first file that needs to be cleaned or smudged,
1076 it starts the filter and performs the handshake. In the handshake, the
1077 welcome message sent by Git is "git-filter-client", only version 2 is
1078 supported, and the supported capabilities are "clean", "smudge", and
1079 "delay".</p>
1080 </div>
1081 <div class="paragraph">
1082 <p>Afterwards Git sends a list of "key=value" pairs terminated with
1083 a flush packet. The list will contain at least the filter command
1084 (based on the supported capabilities) and the pathname of the file
1085 to filter relative to the repository root. Right after the flush packet
1086 Git sends the content split in zero or more pkt-line packets and a
1087 flush packet to terminate content. Please note, that the filter
1088 must not send any response before it received the content and the
1089 final flush packet. Also note that the "value" of a "key=value" pair
1090 can contain the "=" character whereas the key would never contain
1091 that character.</p>
1092 </div>
1093 <div class="listingblock">
1094 <div class="content">
1095 <pre>packet: git&gt; command=smudge
1096 packet: git&gt; pathname=path/testfile.dat
1097 packet: git&gt; 0000
1098 packet: git&gt; CONTENT
1099 packet: git&gt; 0000</pre>
1100 </div>
1101 </div>
1102 <div class="paragraph">
1103 <p>The filter is expected to respond with a list of "key=value" pairs
1104 terminated with a flush packet. If the filter does not experience
1105 problems then the list must contain a "success" status. Right after
1106 these packets the filter is expected to send the content in zero
1107 or more pkt-line packets and a flush packet at the end. Finally, a
1108 second list of "key=value" pairs terminated with a flush packet
1109 is expected. The filter can change the status in the second list
1110 or keep the status as is with an empty list. Please note that the
1111 empty list must be terminated with a flush packet regardless.</p>
1112 </div>
1113 <div class="listingblock">
1114 <div class="content">
1115 <pre>packet: git&lt; status=success
1116 packet: git&lt; 0000
1117 packet: git&lt; SMUDGED_CONTENT
1118 packet: git&lt; 0000
1119 packet: git&lt; 0000 # empty list, keep "status=success" unchanged!</pre>
1120 </div>
1121 </div>
1122 <div class="paragraph">
1123 <p>If the result content is empty then the filter is expected to respond
1124 with a "success" status and a flush packet to signal the empty content.</p>
1125 </div>
1126 <div class="listingblock">
1127 <div class="content">
1128 <pre>packet: git&lt; status=success
1129 packet: git&lt; 0000
1130 packet: git&lt; 0000 # empty content!
1131 packet: git&lt; 0000 # empty list, keep "status=success" unchanged!</pre>
1132 </div>
1133 </div>
1134 <div class="paragraph">
1135 <p>In case the filter cannot or does not want to process the content,
1136 it is expected to respond with an "error" status.</p>
1137 </div>
1138 <div class="listingblock">
1139 <div class="content">
1140 <pre>packet: git&lt; status=error
1141 packet: git&lt; 0000</pre>
1142 </div>
1143 </div>
1144 <div class="paragraph">
1145 <p>If the filter experiences an error during processing, then it can
1146 send the status "error" after the content was (partially or
1147 completely) sent.</p>
1148 </div>
1149 <div class="listingblock">
1150 <div class="content">
1151 <pre>packet: git&lt; status=success
1152 packet: git&lt; 0000
1153 packet: git&lt; HALF_WRITTEN_ERRONEOUS_CONTENT
1154 packet: git&lt; 0000
1155 packet: git&lt; status=error
1156 packet: git&lt; 0000</pre>
1157 </div>
1158 </div>
1159 <div class="paragraph">
1160 <p>In case the filter cannot or does not want to process the content
1161 as well as any future content for the lifetime of the Git process,
1162 then it is expected to respond with an "abort" status at any point
1163 in the protocol.</p>
1164 </div>
1165 <div class="listingblock">
1166 <div class="content">
1167 <pre>packet: git&lt; status=abort
1168 packet: git&lt; 0000</pre>
1169 </div>
1170 </div>
1171 <div class="paragraph">
1172 <p>Git neither stops nor restarts the filter process in case the
1173 "error"/"abort" status is set. However, Git sets its exit code
1174 according to the <code>filter.</code><em>&lt;driver&gt;</em><code>.required</code> flag, mimicking the
1175 behavior of the <code>filter.</code><em>&lt;driver&gt;</em><code>.clean</code> / <code>filter.</code><em>&lt;driver&gt;</em><code>.smudge</code>
1176 mechanism.</p>
1177 </div>
1178 <div class="paragraph">
1179 <p>If the filter dies during the communication or does not adhere to
1180 the protocol then Git will stop the filter process and restart it
1181 with the next file that needs to be processed. Depending on the
1182 <code>filter.</code><em>&lt;driver&gt;</em><code>.required</code> flag Git will interpret that as error.</p>
1183 </div>
1184 </div>
1185 <div class="sect3">
1186 <h4 id="_delay">Delay</h4>
1187 <div class="paragraph">
1188 <p>If the filter supports the "delay" capability, then Git can send the
1189 flag "can-delay" after the filter command and pathname. This flag
1190 denotes that the filter can delay filtering the current blob (e.g. to
1191 compensate network latencies) by responding with no content but with
1192 the status "delayed" and a flush packet.</p>
1193 </div>
1194 <div class="listingblock">
1195 <div class="content">
1196 <pre>packet: git&gt; command=smudge
1197 packet: git&gt; pathname=path/testfile.dat
1198 packet: git&gt; can-delay=1
1199 packet: git&gt; 0000
1200 packet: git&gt; CONTENT
1201 packet: git&gt; 0000
1202 packet: git&lt; status=delayed
1203 packet: git&lt; 0000</pre>
1204 </div>
1205 </div>
1206 <div class="paragraph">
1207 <p>If the filter supports the "delay" capability then it must support the
1208 "list_available_blobs" command. If Git sends this command, then the
1209 filter is expected to return a list of pathnames representing blobs
1210 that have been delayed earlier and are now available.
1211 The list must be terminated with a flush packet followed
1212 by a "success" status that is also terminated with a flush packet. If
1213 no blobs for the delayed paths are available, yet, then the filter is
1214 expected to block the response until at least one blob becomes
1215 available. The filter can tell Git that it has no more delayed blobs
1216 by sending an empty list. As soon as the filter responds with an empty
1217 list, Git stops asking. All blobs that Git has not received at this
1218 point are considered missing and will result in an error.</p>
1219 </div>
1220 <div class="listingblock">
1221 <div class="content">
1222 <pre>packet: git&gt; command=list_available_blobs
1223 packet: git&gt; 0000
1224 packet: git&lt; pathname=path/testfile.dat
1225 packet: git&lt; pathname=path/otherfile.dat
1226 packet: git&lt; 0000
1227 packet: git&lt; status=success
1228 packet: git&lt; 0000</pre>
1229 </div>
1230 </div>
1231 <div class="paragraph">
1232 <p>After Git received the pathnames, it will request the corresponding
1233 blobs again. These requests contain a pathname and an empty content
1234 section. The filter is expected to respond with the smudged content
1235 in the usual way as explained above.</p>
1236 </div>
1237 <div class="listingblock">
1238 <div class="content">
1239 <pre>packet: git&gt; command=smudge
1240 packet: git&gt; pathname=path/testfile.dat
1241 packet: git&gt; 0000
1242 packet: git&gt; 0000 # empty content!
1243 packet: git&lt; status=success
1244 packet: git&lt; 0000
1245 packet: git&lt; SMUDGED_CONTENT
1246 packet: git&lt; 0000
1247 packet: git&lt; 0000 # empty list, keep "status=success" unchanged!</pre>
1248 </div>
1249 </div>
1250 </div>
1251 <div class="sect3">
1252 <h4 id="_example">Example</h4>
1253 <div class="paragraph">
1254 <p>A long running filter demo implementation can be found in
1255 <code>contrib/long-running-filter/example.pl</code> located in the Git
1256 core repository. If you develop your own long running filter
1257 process then the <code>GIT_TRACE_PACKET</code> environment variables can be
1258 very helpful for debugging (see <a href="git.html">git(1)</a>).</p>
1259 </div>
1260 <div class="paragraph">
1261 <p>Please note that you cannot use an existing <code>filter.</code><em>&lt;driver&gt;</em><code>.clean</code>
1262 or <code>filter.</code><em>&lt;driver&gt;</em><code>.smudge</code> command with <code>filter.</code><em>&lt;driver&gt;</em><code>.process</code>
1263 because the former two use a different inter process communication
1264 protocol than the latter one.</p>
1265 </div>
1266 </div>
1267 <div class="sect3">
1268 <h4 id="_interaction_between_checkincheckout_attributes">Interaction between checkin/checkout attributes</h4>
1269 <div class="paragraph">
1270 <p>In the check-in codepath, the worktree file is first converted
1271 with <code>filter</code> driver (if specified and corresponding driver
1272 defined), then the result is processed with <code>ident</code> (if
1273 specified), and then finally with <code>text</code> (again, if specified
1274 and applicable).</p>
1275 </div>
1276 <div class="paragraph">
1277 <p>In the check-out codepath, the blob content is first converted
1278 with <code>text</code>, and then <code>ident</code> and fed to <code>filter</code>.</p>
1279 </div>
1280 </div>
1281 <div class="sect3">
1282 <h4 id="_merging_branches_with_differing_checkincheckout_attributes">Merging branches with differing checkin/checkout attributes</h4>
1283 <div class="paragraph">
1284 <p>If you have added attributes to a file that cause the canonical
1285 repository format for that file to change, such as adding a
1286 clean/smudge filter or text/eol/ident attributes, merging anything
1287 where the attribute is not in place would normally cause merge
1288 conflicts.</p>
1289 </div>
1290 <div class="paragraph">
1291 <p>To prevent these unnecessary merge conflicts, Git can be told to run a
1292 virtual check-out and check-in of all three stages of a file when
1293 resolving a three-way merge by setting the <code>merge.renormalize</code>
1294 configuration variable. This prevents changes caused by check-in
1295 conversion from causing spurious merge conflicts when a converted file
1296 is merged with an unconverted file.</p>
1297 </div>
1298 <div class="paragraph">
1299 <p>As long as a "smudge&#8594;clean" results in the same output as a "clean"
1300 even on files that are already smudged, this strategy will
1301 automatically resolve all filter-related conflicts. Filters that do
1302 not act in this way may cause additional merge conflicts that must be
1303 resolved manually.</p>
1304 </div>
1305 </div>
1306 </div>
1307 <div class="sect2">
1308 <h3 id="_generating_diff_text">Generating diff text</h3>
1309 <div class="sect3">
1310 <h4 id="_diff"><code>diff</code></h4>
1311 <div class="paragraph">
1312 <p>The attribute <code>diff</code> affects how Git generates diffs for particular
1313 files. It can tell Git whether to generate a textual patch for the path
1314 or to treat the path as a binary file. It can also affect what line is
1315 shown on the hunk header <code>@@</code> <code>-k,l</code> <code>+n,m</code> <code>@@</code> line, tell Git to use an
1316 external command to generate the diff, or ask Git to convert binary
1317 files to a text format before generating the diff.</p>
1318 </div>
1319 <div class="dlist">
1320 <dl>
1321 <dt class="hdlist1">Set</dt>
1322 <dd>
1323 <p>A path to which the <code>diff</code> attribute is set is treated
1324 as text, even when they contain byte values that
1325 normally never appear in text files, such as NUL.</p>
1326 </dd>
1327 <dt class="hdlist1">Unset</dt>
1328 <dd>
1329 <p>A path to which the <code>diff</code> attribute is unset will
1330 generate <code>Binary</code> <code>files</code> <code>differ</code> (or a binary patch, if
1331 binary patches are enabled).</p>
1332 </dd>
1333 <dt class="hdlist1">Unspecified</dt>
1334 <dd>
1335 <p>A path to which the <code>diff</code> attribute is unspecified
1336 first gets its contents inspected, and if it looks like
1337 text and is smaller than core.bigFileThreshold, it is treated
1338 as text. Otherwise it would generate <code>Binary</code> <code>files</code> <code>differ</code>.</p>
1339 </dd>
1340 <dt class="hdlist1">String</dt>
1341 <dd>
1342 <p>Diff is shown using the specified diff driver. Each driver may
1343 specify one or more options, as described in the following
1344 section. The options for the diff driver "foo" are defined
1345 by the configuration variables in the "diff.foo" section of the
1346 Git config file.</p>
1347 </dd>
1348 </dl>
1349 </div>
1350 </div>
1351 <div class="sect3">
1352 <h4 id="_defining_an_external_diff_driver">Defining an external diff driver</h4>
1353 <div class="paragraph">
1354 <p>The definition of a diff driver is done in <code>gitconfig</code>, not
1355 <code>gitattributes</code> file, so strictly speaking this manual page is a
1356 wrong place to talk about it. However&#8230;&#8203;</p>
1357 </div>
1358 <div class="paragraph">
1359 <p>To define an external diff driver <code>jcdiff</code>, add a section to your
1360 <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p>
1361 </div>
1362 <div class="listingblock">
1363 <div class="content">
1364 <pre>[diff "jcdiff"]
1365 command = j-c-diff</pre>
1366 </div>
1367 </div>
1368 <div class="paragraph">
1369 <p>When Git needs to show you a diff for the path with <code>diff</code>
1370 attribute set to <code>jcdiff</code>, it calls the command you specified
1371 with the above configuration, i.e. <code>j-c-diff</code>, with 7
1372 parameters, just like <code>GIT_EXTERNAL_DIFF</code> program is called.
1373 See <a href="git.html">git(1)</a> for details.</p>
1374 </div>
1375 <div class="paragraph">
1376 <p>If the program is able to ignore certain changes (similar to
1377 <code>git</code> <code>diff</code> <code>--ignore-space-change</code>), then also set the option
1378 <code>trustExitCode</code> to true. It is then expected to return exit code 1 if
1379 it finds significant changes and 0 if it doesn&#8217;t.</p>
1380 </div>
1381 </div>
1382 <div class="sect3">
1383 <h4 id="_setting_the_internal_diff_algorithm">Setting the internal diff algorithm</h4>
1384 <div class="paragraph">
1385 <p>The diff algorithm can be set through the <code>diff.algorithm</code> config key, but
1386 sometimes it may be helpful to set the diff algorithm per path. For example,
1387 one may want to use the <code>minimal</code> diff algorithm for .json files, and the
1388 <code>histogram</code> for .c files, and so on without having to pass in the algorithm
1389 through the command line each time.</p>
1390 </div>
1391 <div class="paragraph">
1392 <p>First, in .<code>gitattributes</code>, assign the <code>diff</code> attribute for paths.</p>
1393 </div>
1394 <div class="listingblock">
1395 <div class="content">
1396 <pre>*.json diff=&lt;name&gt;</pre>
1397 </div>
1398 </div>
1399 <div class="paragraph">
1400 <p>Then, define a "diff.&lt;name&gt;.algorithm" configuration to specify the diff
1401 algorithm, choosing from <code>myers</code>, <code>patience</code>, <code>minimal</code>, or <code>histogram</code>.</p>
1402 </div>
1403 <div class="listingblock">
1404 <div class="content">
1405 <pre>[diff "&lt;name&gt;"]
1406 algorithm = histogram</pre>
1407 </div>
1408 </div>
1409 <div class="paragraph">
1410 <p>This diff algorithm applies to user facing diff output like git-diff(1),
1411 git-show(1) and is used for the <code>--stat</code> output as well. The merge machinery
1412 will not use the diff algorithm set through this method.</p>
1413 </div>
1414 <div class="admonitionblock note">
1415 <table>
1416 <tr>
1417 <td class="icon">
1418 <div class="title">Note</div>
1419 </td>
1420 <td class="content">
1421 If <code>diff.</code><em>&lt;name&gt;</em><code>.command</code> is defined for path with the
1422 <code>diff=</code><em>&lt;name&gt;</em> attribute, it is executed as an external diff driver
1423 (see above), and adding <code>diff.</code><em>&lt;name&gt;</em><code>.algorithm</code> has no effect, as the
1424 algorithm is not passed to the external diff driver.
1425 </td>
1426 </tr>
1427 </table>
1428 </div>
1429 </div>
1430 <div class="sect3">
1431 <h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4>
1432 <div class="paragraph">
1433 <p>Each group of changes (called a "hunk") in the textual diff output
1434 is prefixed with a line of the form:</p>
1435 </div>
1436 <div class="literalblock">
1437 <div class="content">
1438 <pre>@@ -k,l +n,m @@ TEXT</pre>
1439 </div>
1440 </div>
1441 <div class="paragraph">
1442 <p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line
1443 that begins with an alphabet, an underscore or a dollar sign; this
1444 matches what GNU <em>diff -p</em> output uses. This default selection however
1445 is not suited for some contents, and you can use a customized pattern
1446 to make a selection.</p>
1447 </div>
1448 <div class="paragraph">
1449 <p>First, in .gitattributes, you would assign the <code>diff</code> attribute
1450 for paths.</p>
1451 </div>
1452 <div class="listingblock">
1453 <div class="content">
1454 <pre>*.tex diff=tex</pre>
1455 </div>
1456 </div>
1457 <div class="paragraph">
1458 <p>Then, you would define a "diff.tex.xfuncname" configuration to
1459 specify a regular expression that matches a line that you would
1460 want to appear as the hunk header "TEXT". Add a section to your
1461 <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p>
1462 </div>
1463 <div class="listingblock">
1464 <div class="content">
1465 <pre>[diff "tex"]
1466 xfuncname = "^(\\\\(sub)*section\\{.*)$"</pre>
1467 </div>
1468 </div>
1469 <div class="paragraph">
1470 <p>Note. A single level of backslashes are eaten by the
1471 configuration file parser, so you would need to double the
1472 backslashes; the pattern above picks a line that begins with a
1473 backslash, and zero or more occurrences of <code>sub</code> followed by
1474 <code>section</code> followed by open brace, to the end of line.</p>
1475 </div>
1476 <div class="paragraph">
1477 <p>There are a few built-in patterns to make this easier, and <code>tex</code>
1478 is one of them, so you do not have to write the above in your
1479 configuration file (you still need to enable this with the
1480 attribute mechanism, via .<code>gitattributes</code>). The following built in
1481 patterns are available:</p>
1482 </div>
1483 <div class="ulist">
1484 <ul>
1485 <li>
1486 <p><code>ada</code> suitable for source code in the Ada language.</p>
1487 </li>
1488 <li>
1489 <p><code>bash</code> suitable for source code in the Bourne-Again SHell language.
1490 Covers a superset of POSIX shell function definitions.</p>
1491 </li>
1492 <li>
1493 <p><code>bibtex</code> suitable for files with BibTeX coded references.</p>
1494 </li>
1495 <li>
1496 <p><code>cpp</code> suitable for source code in the C and C++ languages.</p>
1497 </li>
1498 <li>
1499 <p><code>csharp</code> suitable for source code in the C# language.</p>
1500 </li>
1501 <li>
1502 <p><code>css</code> suitable for cascading style sheets.</p>
1503 </li>
1504 <li>
1505 <p><code>dts</code> suitable for devicetree (DTS) files.</p>
1506 </li>
1507 <li>
1508 <p><code>elixir</code> suitable for source code in the Elixir language.</p>
1509 </li>
1510 <li>
1511 <p><code>fortran</code> suitable for source code in the Fortran language.</p>
1512 </li>
1513 <li>
1514 <p><code>fountain</code> suitable for Fountain documents.</p>
1515 </li>
1516 <li>
1517 <p><code>golang</code> suitable for source code in the Go language.</p>
1518 </li>
1519 <li>
1520 <p><code>html</code> suitable for HTML/XHTML documents.</p>
1521 </li>
1522 <li>
1523 <p><code>java</code> suitable for source code in the Java language.</p>
1524 </li>
1525 <li>
1526 <p><code>kotlin</code> suitable for source code in the Kotlin language.</p>
1527 </li>
1528 <li>
1529 <p><code>markdown</code> suitable for Markdown documents.</p>
1530 </li>
1531 <li>
1532 <p><code>matlab</code> suitable for source code in the MATLAB and Octave languages.</p>
1533 </li>
1534 <li>
1535 <p><code>objc</code> suitable for source code in the Objective-C language.</p>
1536 </li>
1537 <li>
1538 <p><code>pascal</code> suitable for source code in the Pascal/Delphi language.</p>
1539 </li>
1540 <li>
1541 <p><code>perl</code> suitable for source code in the Perl language.</p>
1542 </li>
1543 <li>
1544 <p><code>php</code> suitable for source code in the PHP language.</p>
1545 </li>
1546 <li>
1547 <p><code>python</code> suitable for source code in the Python language.</p>
1548 </li>
1549 <li>
1550 <p><code>ruby</code> suitable for source code in the Ruby language.</p>
1551 </li>
1552 <li>
1553 <p><code>rust</code> suitable for source code in the Rust language.</p>
1554 </li>
1555 <li>
1556 <p><code>scheme</code> suitable for source code in the Scheme language.</p>
1557 </li>
1558 <li>
1559 <p><code>tex</code> suitable for source code for LaTeX documents.</p>
1560 </li>
1561 </ul>
1562 </div>
1563 </div>
1564 <div class="sect3">
1565 <h4 id="_customizing_word_diff">Customizing word diff</h4>
1566 <div class="paragraph">
1567 <p>You can customize the rules that <code>git</code> <code>diff</code> <code>--word-diff</code> uses to
1568 split words in a line, by specifying an appropriate regular expression
1569 in the "diff.*.wordRegex" configuration variable. For example, in TeX
1570 a backslash followed by a sequence of letters forms a command, but
1571 several such commands can be run together without intervening
1572 whitespace. To separate them, use a regular expression in your
1573 <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p>
1574 </div>
1575 <div class="listingblock">
1576 <div class="content">
1577 <pre>[diff "tex"]
1578 wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</pre>
1579 </div>
1580 </div>
1581 <div class="paragraph">
1582 <p>A built-in pattern is provided for all languages listed in the
1583 previous section.</p>
1584 </div>
1585 </div>
1586 <div class="sect3">
1587 <h4 id="_performing_text_diffs_of_binary_files">Performing text diffs of binary files</h4>
1588 <div class="paragraph">
1589 <p>Sometimes it is desirable to see the diff of a text-converted
1590 version of some binary files. For example, a word processor
1591 document can be converted to an ASCII text representation, and
1592 the diff of the text shown. Even though this conversion loses
1593 some information, the resulting diff is useful for human
1594 viewing (but cannot be applied directly).</p>
1595 </div>
1596 <div class="paragraph">
1597 <p>The <code>textconv</code> config option is used to define a program for
1598 performing such a conversion. The program should take a single
1599 argument, the name of a file to convert, and produce the
1600 resulting text on stdout.</p>
1601 </div>
1602 <div class="paragraph">
1603 <p>For example, to show the diff of the exif information of a
1604 file instead of the binary information (assuming you have the
1605 exif tool installed), add the following section to your
1606 <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file):</p>
1607 </div>
1608 <div class="listingblock">
1609 <div class="content">
1610 <pre>[diff "jpg"]
1611 textconv = exif</pre>
1612 </div>
1613 </div>
1614 <div class="admonitionblock note">
1615 <table>
1616 <tr>
1617 <td class="icon">
1618 <div class="title">Note</div>
1619 </td>
1620 <td class="content">
1621 The text conversion is generally a one-way conversion;
1622 in this example, we lose the actual image contents and focus
1623 just on the text data. This means that diffs generated by
1624 textconv are <em>not</em> suitable for applying. For this reason,
1625 only <code>git</code> <code>diff</code> and the <code>git</code> <code>log</code> family of commands (i.e.,
1626 log, whatchanged, show) will perform text conversion. <code>git</code>
1627 <code>format-patch</code> will never generate this output. If you want to
1628 send somebody a text-converted diff of a binary file (e.g.,
1629 because it quickly conveys the changes you have made), you
1630 should generate it separately and send it as a comment <em>in
1631 addition to</em> the usual binary diff that you might send.
1632 </td>
1633 </tr>
1634 </table>
1635 </div>
1636 <div class="paragraph">
1637 <p>Because text conversion can be slow, especially when doing a
1638 large number of them with <code>git</code> <code>log</code> <code>-p</code>, Git provides a mechanism
1639 to cache the output and use it in future diffs. To enable
1640 caching, set the "cachetextconv" variable in your diff driver&#8217;s
1641 config. For example:</p>
1642 </div>
1643 <div class="listingblock">
1644 <div class="content">
1645 <pre>[diff "jpg"]
1646 textconv = exif
1647 cachetextconv = true</pre>
1648 </div>
1649 </div>
1650 <div class="paragraph">
1651 <p>This will cache the result of running "exif" on each blob
1652 indefinitely. If you change the textconv config variable for a
1653 diff driver, Git will automatically invalidate the cache entries
1654 and re-run the textconv filter. If you want to invalidate the
1655 cache manually (e.g., because your version of "exif" was updated
1656 and now produces better output), you can remove the cache
1657 manually with <code>git</code> <code>update-ref</code> <code>-d</code> <code>refs/notes/textconv/jpg</code> (where
1658 "jpg" is the name of the diff driver, as in the example above).</p>
1659 </div>
1660 </div>
1661 <div class="sect3">
1662 <h4 id="_choosing_textconv_versus_external_diff">Choosing textconv versus external diff</h4>
1663 <div class="paragraph">
1664 <p>If you want to show differences between binary or specially-formatted
1665 blobs in your repository, you can choose to use either an external diff
1666 command, or to use textconv to convert them to a diff-able text format.
1667 Which method you choose depends on your exact situation.</p>
1668 </div>
1669 <div class="paragraph">
1670 <p>The advantage of using an external diff command is flexibility. You are
1671 not bound to find line-oriented changes, nor is it necessary for the
1672 output to resemble unified diff. You are free to locate and report
1673 changes in the most appropriate way for your data format.</p>
1674 </div>
1675 <div class="paragraph">
1676 <p>A textconv, by comparison, is much more limiting. You provide a
1677 transformation of the data into a line-oriented text format, and Git
1678 uses its regular diff tools to generate the output. There are several
1679 advantages to choosing this method:</p>
1680 </div>
1681 <div class="olist arabic">
1682 <ol class="arabic">
1683 <li>
1684 <p>Ease of use. It is often much simpler to write a binary to text
1685 transformation than it is to perform your own diff. In many cases,
1686 existing programs can be used as textconv filters (e.g., exif,
1687 odt2txt).</p>
1688 </li>
1689 <li>
1690 <p>Git diff features. By performing only the transformation step
1691 yourself, you can still utilize many of Git&#8217;s diff features,
1692 including colorization, word-diff, and combined diffs for merges.</p>
1693 </li>
1694 <li>
1695 <p>Caching. Textconv caching can speed up repeated diffs, such as those
1696 you might trigger by running <code>git</code> <code>log</code> <code>-p</code>.</p>
1697 </li>
1698 </ol>
1699 </div>
1700 </div>
1701 <div class="sect3">
1702 <h4 id="_marking_files_as_binary">Marking files as binary</h4>
1703 <div class="paragraph">
1704 <p>Git usually guesses correctly whether a blob contains text or binary
1705 data by examining the beginning of the contents. However, sometimes you
1706 may want to override its decision, either because a blob contains binary
1707 data later in the file, or because the content, while technically
1708 composed of text characters, is opaque to a human reader. For example,
1709 many postscript files contain only ASCII characters, but produce noisy
1710 and meaningless diffs.</p>
1711 </div>
1712 <div class="paragraph">
1713 <p>The simplest way to mark a file as binary is to unset the diff
1714 attribute in the .<code>gitattributes</code> file:</p>
1715 </div>
1716 <div class="listingblock">
1717 <div class="content">
1718 <pre>*.ps -diff</pre>
1719 </div>
1720 </div>
1721 <div class="paragraph">
1722 <p>This will cause Git to generate <code>Binary</code> <code>files</code> <code>differ</code> (or a binary
1723 patch, if binary patches are enabled) instead of a regular diff.</p>
1724 </div>
1725 <div class="paragraph">
1726 <p>However, one may also want to specify other diff driver attributes. For
1727 example, you might want to use <code>textconv</code> to convert postscript files to
1728 an ASCII representation for human viewing, but otherwise treat them as
1729 binary files. You cannot specify both <code>-diff</code> and <code>diff=ps</code> attributes.
1730 The solution is to use the <code>diff.</code>*.<code>binary</code> config option:</p>
1731 </div>
1732 <div class="listingblock">
1733 <div class="content">
1734 <pre>[diff "ps"]
1735 textconv = ps2ascii
1736 binary = true</pre>
1737 </div>
1738 </div>
1739 </div>
1740 </div>
1741 <div class="sect2">
1742 <h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3>
1743 <div class="sect3">
1744 <h4 id="_merge"><code>merge</code></h4>
1745 <div class="paragraph">
1746 <p>The attribute <code>merge</code> affects how three versions of a file are
1747 merged when a file-level merge is necessary during <code>git</code> <code>merge</code>,
1748 and other commands such as <code>git</code> <code>revert</code> and <code>git</code> <code>cherry-pick</code>.</p>
1749 </div>
1750 <div class="dlist">
1751 <dl>
1752 <dt class="hdlist1">Set</dt>
1753 <dd>
1754 <p>Built-in 3-way merge driver is used to merge the
1755 contents in a way similar to <em>merge</em> command of <code>RCS</code>
1756 suite. This is suitable for ordinary text files.</p>
1757 </dd>
1758 <dt class="hdlist1">Unset</dt>
1759 <dd>
1760 <p>Take the version from the current branch as the
1761 tentative merge result, and declare that the merge has
1762 conflicts. This is suitable for binary files that do
1763 not have a well-defined merge semantics.</p>
1764 </dd>
1765 <dt class="hdlist1">Unspecified</dt>
1766 <dd>
1767 <p>By default, this uses the same built-in 3-way merge
1768 driver as is the case when the <code>merge</code> attribute is set.
1769 However, the <code>merge.default</code> configuration variable can name
1770 different merge driver to be used with paths for which the
1771 <code>merge</code> attribute is unspecified.</p>
1772 </dd>
1773 <dt class="hdlist1">String</dt>
1774 <dd>
1775 <p>3-way merge is performed using the specified custom
1776 merge driver. The built-in 3-way merge driver can be
1777 explicitly specified by asking for "text" driver; the
1778 built-in "take the current branch" driver can be
1779 requested with "binary".</p>
1780 </dd>
1781 </dl>
1782 </div>
1783 </div>
1784 <div class="sect3">
1785 <h4 id="_built_in_merge_drivers">Built-in merge drivers</h4>
1786 <div class="paragraph">
1787 <p>There are a few built-in low-level merge drivers defined that
1788 can be asked for via the <code>merge</code> attribute.</p>
1789 </div>
1790 <div class="dlist">
1791 <dl>
1792 <dt class="hdlist1">text</dt>
1793 <dd>
1794 <p>Usual 3-way file level merge for text files. Conflicted
1795 regions are marked with conflict markers &lt;&lt;&lt;&lt;&lt;&lt;&lt;,
1796 <code>=======</code> and &gt;&gt;&gt;&gt;&gt;&gt;&gt;. The version from your branch
1797 appears before the <code>=======</code> marker, and the version
1798 from the merged branch appears after the <code>=======</code>
1799 marker.</p>
1800 </dd>
1801 <dt class="hdlist1">binary</dt>
1802 <dd>
1803 <p>Keep the version from your branch in the work tree, but
1804 leave the path in the conflicted state for the user to
1805 sort out.</p>
1806 </dd>
1807 <dt class="hdlist1">union</dt>
1808 <dd>
1809 <p>Run 3-way file level merge for text files, but take
1810 lines from both versions, instead of leaving conflict
1811 markers. This tends to leave the added lines in the
1812 resulting file in random order and the user should
1813 verify the result. Do not use this if you do not
1814 understand the implications.</p>
1815 </dd>
1816 </dl>
1817 </div>
1818 </div>
1819 <div class="sect3">
1820 <h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4>
1821 <div class="paragraph">
1822 <p>The definition of a merge driver is done in the .<code>git/config</code>
1823 file, not in the <code>gitattributes</code> file, so strictly speaking this
1824 manual page is a wrong place to talk about it. However&#8230;&#8203;</p>
1825 </div>
1826 <div class="paragraph">
1827 <p>To define a custom merge driver <code>filfre</code>, add a section to your
1828 <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p>
1829 </div>
1830 <div class="listingblock">
1831 <div class="content">
1832 <pre>[merge "filfre"]
1833 name = feel-free merge driver
1834 driver = filfre %O %A %B %L %P
1835 recursive = binary</pre>
1836 </div>
1837 </div>
1838 <div class="paragraph">
1839 <p>The <code>merge.</code>*.<code>name</code> variable gives the driver a human-readable
1840 name.</p>
1841 </div>
1842 <div class="paragraph">
1843 <p>The <code>merge.</code>*.<code>driver</code> variable&#8217;s value is used to construct a
1844 command to run to common ancestor&#8217;s version (%O), current
1845 version (%A) and the other branches' version (%B). These
1846 three tokens are replaced with the names of temporary files that
1847 hold the contents of these versions when the command line is
1848 built. Additionally, %L will be replaced with the conflict marker
1849 size (see below).</p>
1850 </div>
1851 <div class="paragraph">
1852 <p>The merge driver is expected to leave the result of the merge in
1853 the file named with %A by overwriting it, and exit with zero
1854 status if it managed to merge them cleanly, or non-zero if there
1855 were conflicts. When the driver crashes (e.g. killed by SEGV),
1856 it is expected to exit with non-zero status that are higher than
1857 128, and in such a case, the merge results in a failure (which is
1858 different from producing a conflict).</p>
1859 </div>
1860 <div class="paragraph">
1861 <p>The <code>merge.</code>*.<code>recursive</code> variable specifies what other merge
1862 driver to use when the merge driver is called for an internal
1863 merge between common ancestors, when there are more than one.
1864 When left unspecified, the driver itself is used for both
1865 internal merge and the final merge.</p>
1866 </div>
1867 <div class="paragraph">
1868 <p>The merge driver can learn the pathname in which the merged result
1869 will be stored via placeholder %P. The conflict labels to be used
1870 for the common ancestor, local head and other head can be passed by
1871 using <em>%S</em>, <em>%X</em> and '%Y` respectively.</p>
1872 </div>
1873 </div>
1874 <div class="sect3">
1875 <h4 id="_conflict_marker_size"><code>conflict-marker-size</code></h4>
1876 <div class="paragraph">
1877 <p>This attribute controls the length of conflict markers left in
1878 the work tree file during a conflicted merge. Only a positive
1879 integer has a meaningful effect.</p>
1880 </div>
1881 <div class="paragraph">
1882 <p>For example, this line in .<code>gitattributes</code> can be used to tell the merge
1883 machinery to leave much longer (instead of the usual 7-character-long)
1884 conflict markers when merging the file <code>Documentation/git-merge.txt</code>
1885 results in a conflict.</p>
1886 </div>
1887 <div class="listingblock">
1888 <div class="content">
1889 <pre>Documentation/git-merge.txt conflict-marker-size=32</pre>
1890 </div>
1891 </div>
1892 </div>
1893 </div>
1894 <div class="sect2">
1895 <h3 id="_checking_whitespace_errors">Checking whitespace errors</h3>
1896 <div class="sect3">
1897 <h4 id="_whitespace"><code>whitespace</code></h4>
1898 <div class="paragraph">
1899 <p>The <code>core.whitespace</code> configuration variable allows you to define what
1900 <em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in
1901 the project (See <a href="git-config.html">git-config(1)</a>). This attribute gives you finer
1902 control per path.</p>
1903 </div>
1904 <div class="dlist">
1905 <dl>
1906 <dt class="hdlist1">Set</dt>
1907 <dd>
1908 <p>Notice all types of potential whitespace errors known to Git.
1909 The tab width is taken from the value of the <code>core.whitespace</code>
1910 configuration variable.</p>
1911 </dd>
1912 <dt class="hdlist1">Unset</dt>
1913 <dd>
1914 <p>Do not notice anything as error.</p>
1915 </dd>
1916 <dt class="hdlist1">Unspecified</dt>
1917 <dd>
1918 <p>Use the value of the <code>core.whitespace</code> configuration variable to
1919 decide what to notice as error.</p>
1920 </dd>
1921 <dt class="hdlist1">String</dt>
1922 <dd>
1923 <p>Specify a comma separated list of common whitespace problems to
1924 notice in the same format as the <code>core.whitespace</code> configuration
1925 variable.</p>
1926 </dd>
1927 </dl>
1928 </div>
1929 </div>
1930 </div>
1931 <div class="sect2">
1932 <h3 id="_creating_an_archive">Creating an archive</h3>
1933 <div class="sect3">
1934 <h4 id="_export_ignore"><code>export-ignore</code></h4>
1935 <div class="paragraph">
1936 <p>Files and directories with the attribute <code>export-ignore</code> won&#8217;t be added to
1937 archive files.</p>
1938 </div>
1939 </div>
1940 <div class="sect3">
1941 <h4 id="_export_subst"><code>export-subst</code></h4>
1942 <div class="paragraph">
1943 <p>If the attribute <code>export-subst</code> is set for a file then Git will expand
1944 several placeholders when adding this file to an archive. The
1945 expansion depends on the availability of a commit ID, i.e., if
1946 <a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a
1947 tag then no replacement will be done. The placeholders are the same
1948 as those for the option <code>--pretty=format:</code> of <a href="git-log.html">git-log(1)</a>,
1949 except that they need to be wrapped like this: <code>$Format:PLACEHOLDERS$</code>
1950 in the file. E.g. the string <code>$Format:</code>%H$ will be replaced by the
1951 commit hash. However, only one %(<code>describe</code>) placeholder is expanded
1952 per archive to avoid denial-of-service attacks.</p>
1953 </div>
1954 </div>
1955 </div>
1956 <div class="sect2">
1957 <h3 id="_packing_objects">Packing objects</h3>
1958 <div class="sect3">
1959 <h4 id="_delta"><code>delta</code></h4>
1960 <div class="paragraph">
1961 <p>Delta compression will not be attempted for blobs for paths with the
1962 attribute <code>delta</code> set to false.</p>
1963 </div>
1964 </div>
1965 </div>
1966 <div class="sect2">
1967 <h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3>
1968 <div class="sect3">
1969 <h4 id="_encoding"><code>encoding</code></h4>
1970 <div class="paragraph">
1971 <p>The value of this attribute specifies the character encoding that should
1972 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
1973 display the contents of the relevant file. Note that due to performance
1974 considerations <a href="gitk.html">gitk(1)</a> does not use this attribute unless you
1975 manually enable per-file encodings in its options.</p>
1976 </div>
1977 <div class="paragraph">
1978 <p>If this attribute is not set or has an invalid value, the value of the
1979 <code>gui.encoding</code> configuration variable is used instead
1980 (See <a href="git-config.html">git-config(1)</a>).</p>
1981 </div>
1982 </div>
1983 </div>
1984 </div>
1985 </div>
1986 <div class="sect1">
1987 <h2 id="_using_macro_attributes">USING MACRO ATTRIBUTES</h2>
1988 <div class="sectionbody">
1989 <div class="paragraph">
1990 <p>You do not want any end-of-line conversions applied to, nor textual diffs
1991 produced for, any binary file you track. You would need to specify e.g.</p>
1992 </div>
1993 <div class="listingblock">
1994 <div class="content">
1995 <pre>*.jpg -text -diff</pre>
1996 </div>
1997 </div>
1998 <div class="paragraph">
1999 <p>but that may become cumbersome, when you have many attributes. Using
2000 macro attributes, you can define an attribute that, when set, also
2001 sets or unsets a number of other attributes at the same time. The
2002 system knows a built-in macro attribute, <code>binary</code>:</p>
2003 </div>
2004 <div class="listingblock">
2005 <div class="content">
2006 <pre>*.jpg binary</pre>
2007 </div>
2008 </div>
2009 <div class="paragraph">
2010 <p>Setting the "binary" attribute also unsets the "text" and "diff"
2011 attributes as above. Note that macro attributes can only be "Set",
2012 though setting one might have the effect of setting or unsetting other
2013 attributes or even returning other attributes to the "Unspecified"
2014 state.</p>
2015 </div>
2016 </div>
2017 </div>
2018 <div class="sect1">
2019 <h2 id="_defining_macro_attributes">DEFINING MACRO ATTRIBUTES</h2>
2020 <div class="sectionbody">
2021 <div class="paragraph">
2022 <p>Custom macro attributes can be defined only in top-level gitattributes
2023 files (<code>$GIT_DIR/info/attributes</code>, the .<code>gitattributes</code> file at the
2024 top level of the working tree, or the global or system-wide
2025 gitattributes files), not in .<code>gitattributes</code> files in working tree
2026 subdirectories. The built-in macro attribute "binary" is equivalent
2027 to:</p>
2028 </div>
2029 <div class="listingblock">
2030 <div class="content">
2031 <pre>[attr]binary -diff -merge -text</pre>
2032 </div>
2033 </div>
2034 </div>
2035 </div>
2036 <div class="sect1">
2037 <h2 id="_notes">NOTES</h2>
2038 <div class="sectionbody">
2039 <div class="paragraph">
2040 <p>Git does not follow symbolic links when accessing a .<code>gitattributes</code>
2041 file in the working tree. This keeps behavior consistent when the file
2042 is accessed from the index or a tree versus from the filesystem.</p>
2043 </div>
2044 </div>
2045 </div>
2046 <div class="sect1">
2047 <h2 id="_examples">EXAMPLES</h2>
2048 <div class="sectionbody">
2049 <div class="paragraph">
2050 <p>If you have these three <code>gitattributes</code> file:</p>
2051 </div>
2052 <div class="listingblock">
2053 <div class="content">
2054 <pre>(in $GIT_DIR/info/attributes)
2056 a* foo !bar -baz
2058 (in .gitattributes)
2059 abc foo bar baz
2061 (in t/.gitattributes)
2062 ab* merge=filfre
2063 abc -foo -bar
2064 *.c frotz</pre>
2065 </div>
2066 </div>
2067 <div class="paragraph">
2068 <p>the attributes given to path <code>t/abc</code> are computed as follows:</p>
2069 </div>
2070 <div class="olist arabic">
2071 <ol class="arabic">
2072 <li>
2073 <p>By examining <code>t/.gitattributes</code> (which is in the same
2074 directory as the path in question), Git finds that the first
2075 line matches. <code>merge</code> attribute is set. It also finds that
2076 the second line matches, and attributes <code>foo</code> and <code>bar</code>
2077 are unset.</p>
2078 </li>
2079 <li>
2080 <p>Then it examines .<code>gitattributes</code> (which is in the parent
2081 directory), and finds that the first line matches, but
2082 <code>t/.gitattributes</code> file already decided how <code>merge</code>, <code>foo</code>
2083 and <code>bar</code> attributes should be given to this path, so it
2084 leaves <code>foo</code> and <code>bar</code> unset. Attribute <code>baz</code> is set.</p>
2085 </li>
2086 <li>
2087 <p>Finally it examines <code>$GIT_DIR/info/attributes</code>. This file
2088 is used to override the in-tree settings. The first line is
2089 a match, and <code>foo</code> is set, <code>bar</code> is reverted to unspecified
2090 state, and <code>baz</code> is unset.</p>
2091 </li>
2092 </ol>
2093 </div>
2094 <div class="paragraph">
2095 <p>As the result, the attributes assignment to <code>t/abc</code> becomes:</p>
2096 </div>
2097 <div class="listingblock">
2098 <div class="content">
2099 <pre>foo set to true
2100 bar unspecified
2101 baz set to false
2102 merge set to string value "filfre"
2103 frotz unspecified</pre>
2104 </div>
2105 </div>
2106 </div>
2107 </div>
2108 <div class="sect1">
2109 <h2 id="_see_also">SEE ALSO</h2>
2110 <div class="sectionbody">
2111 <div class="paragraph">
2112 <p><a href="git-check-attr.html">git-check-attr(1)</a>.</p>
2113 </div>
2114 </div>
2115 </div>
2116 <div class="sect1">
2117 <h2 id="_git">GIT</h2>
2118 <div class="sectionbody">
2119 <div class="paragraph">
2120 <p>Part of the <a href="git.html">git(1)</a> suite</p>
2121 </div>
2122 </div>
2123 </div>
2124 </div>
2125 <div id="footer">
2126 <div id="footer-text">
2127 Last updated 2024-07-08 15:33:45 -0700
2128 </div>
2129 </div>
2130 </body>
2131 </html>