blob: fca248c5f9200f6d30671a94c2f44eb2fa8fbe4f [file] [log] [blame]
Junio C Hamanoe90436a2007-04-22 07:22:131<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanoeef01fe2010-12-13 08:31:586<meta name="generator" content="AsciiDoc 8.4.5" />
7<title>gitattributes(5)</title>
Junio C Hamanoe90436a2007-04-22 07:22:138<style type="text/css">
9/* Debug borders */
10p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11/*
12 border: 1px solid red;
13*/
14}
15
16body {
17 margin: 1em 5% 1em 5%;
18}
19
Junio C Hamanoba4b9282008-07-06 05:20:3120a {
21 color: blue;
22 text-decoration: underline;
23}
24a:visited {
25 color: fuchsia;
26}
Junio C Hamanoe90436a2007-04-22 07:22:1327
28em {
29 font-style: italic;
Junio C Hamanoeef01fe2010-12-13 08:31:5830 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:1331}
32
33strong {
34 font-weight: bold;
Junio C Hamanoeef01fe2010-12-13 08:31:5835 color: #083194;
Junio C Hamanoe90436a2007-04-22 07:22:1336}
37
38tt {
39 color: navy;
40}
41
42h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
48}
49
Junio C Hamanoba4b9282008-07-06 05:20:3150h1, h2, h3 {
Junio C Hamanoe90436a2007-04-22 07:22:1351 border-bottom: 2px solid silver;
52}
53h2 {
Junio C Hamanoe90436a2007-04-22 07:22:1354 padding-top: 0.5em;
55}
Junio C Hamanoba4b9282008-07-06 05:20:3156h3 {
57 float: left;
58}
59h3 + * {
60 clear: left;
61}
Junio C Hamanoe90436a2007-04-22 07:22:1362
63div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
66}
67
68hr {
69 border: 1px solid silver;
70}
71
72p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
75}
76
Junio C Hamanoeef01fe2010-12-13 08:31:5877ul, ol, li > p {
78 margin-top: 0;
79}
80
Junio C Hamanoe90436a2007-04-22 07:22:1381pre {
82 padding: 0;
83 margin: 0;
84}
85
86span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3190 font-size: 1.1em;
Junio C Hamanoe90436a2007-04-22 07:22:1391}
92span#email {
93}
Junio C Hamanoeef01fe2010-12-13 08:31:5894span#revnumber, span#revdate, span#revremark {
Junio C Hamanoe90436a2007-04-22 07:22:1395 font-family: sans-serif;
96}
97
98div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
104}
105div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
108}
109div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
112}
113
Junio C Hamanoeef01fe2010-12-13 08:31:58114div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
117}
Junio C Hamanoe90436a2007-04-22 07:22:13118div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120div.admonitionblock {
Junio C Hamanoe90436a2007-04-22 07:22:13121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
123}
124div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
127}
128
129div.content { /* Block element content. */
130 padding: 0;
131}
132
133/* Block element titles. */
134div.title, caption.title {
Junio C Hamanoeef01fe2010-12-13 08:31:58135 color: #527bbd;
Junio C Hamanoe90436a2007-04-22 07:22:13136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
141}
142div.title + * {
143 margin-top: 0;
144}
145
146td div.title:first-child {
147 margin-top: 0.0em;
148}
149div.content div.title:first-child {
150 margin-top: 0.0em;
151}
152div.content + div.title {
153 margin-top: 0.0em;
154}
155
156div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
160}
161
162div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
166}
167
Junio C Hamanoeef01fe2010-12-13 08:31:58168div.quoteblock {
Junio C Hamanoe90436a2007-04-22 07:22:13169 padding-left: 2.0em;
Junio C Hamanoeef01fe2010-12-13 08:31:58170 margin-right: 10%;
Junio C Hamanoe90436a2007-04-22 07:22:13171}
Junio C Hamanoeef01fe2010-12-13 08:31:58172div.quoteblock > div.attribution {
173 padding-top: 0.5em;
Junio C Hamanoe90436a2007-04-22 07:22:13174 text-align: right;
175}
Junio C Hamanoeef01fe2010-12-13 08:31:58176
177div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
180}
181div.verseblock > div.content {
182 white-space: pre;
183}
184div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
187}
188/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamanoba4b9282008-07-06 05:20:31189div.verseblock + div.attribution {
190 text-align: left;
191}
Junio C Hamanoe90436a2007-04-22 07:22:13192
193div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
200}
201div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
204}
205
206div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
209}
210
Junio C Hamanoe90436a2007-04-22 07:22:13211div.imageblock div.content { padding-left: 0; }
Junio C Hamanoe90436a2007-04-22 07:22:13212span.image img { border-style: none; }
Junio C Hamanoeef01fe2010-12-13 08:31:58213a.image:visited { color: white; }
Junio C Hamanoe90436a2007-04-22 07:22:13214
215dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
218}
219dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
Junio C Hamanoeef01fe2010-12-13 08:31:58222 font-style: normal;
223 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:13224}
225dd > *:first-child {
Junio C Hamanoeef01fe2010-12-13 08:31:58226 margin-top: 0.1em;
Junio C Hamanoe90436a2007-04-22 07:22:13227}
228
229ul, ol {
230 list-style-position: outside;
231}
Junio C Hamanoeef01fe2010-12-13 08:31:58232ol.arabic {
233 list-style-type: decimal;
234}
235ol.loweralpha {
Junio C Hamanoe90436a2007-04-22 07:22:13236 list-style-type: lower-alpha;
237}
Junio C Hamanoeef01fe2010-12-13 08:31:58238ol.upperalpha {
239 list-style-type: upper-alpha;
240}
241ol.lowerroman {
242 list-style-type: lower-roman;
243}
244ol.upperroman {
245 list-style-type: upper-roman;
246}
247
248div.compact ul, div.compact ol,
249div.compact p, div.compact p,
250div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
253}
Junio C Hamanoe90436a2007-04-22 07:22:13254
255div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31256 border: 3px solid #527bbd;
Junio C Hamanoe90436a2007-04-22 07:22:13257}
258thead {
259 font-family: sans-serif;
260 font-weight: bold;
261}
262tfoot {
263 font-weight: bold;
264}
Junio C Hamanoeef01fe2010-12-13 08:31:58265td > div.verse {
266 white-space: pre;
267}
268p.table {
269 margin-top: 0;
270}
271/* Because the table frame attribute is overriden by CSS in most browsers. */
272div.tableblock > table[frame="void"] {
273 border-style: none;
274}
275div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
278}
279div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
282}
Junio C Hamanoe90436a2007-04-22 07:22:13283
Junio C Hamanoeef01fe2010-12-13 08:31:58284
285div.hdlist {
Junio C Hamanoe90436a2007-04-22 07:22:13286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
288}
Junio C Hamanoeef01fe2010-12-13 08:31:58289div.hdlist tr {
290 padding-bottom: 15px;
Junio C Hamanoba4b9282008-07-06 05:20:31291}
Junio C Hamanoeef01fe2010-12-13 08:31:58292dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
294}
295td.hdlist1 {
Junio C Hamanoe90436a2007-04-22 07:22:13296 vertical-align: top;
Junio C Hamanoeef01fe2010-12-13 08:31:58297 font-style: normal;
Junio C Hamanoe90436a2007-04-22 07:22:13298 padding-right: 0.8em;
Junio C Hamanoeef01fe2010-12-13 08:31:58299 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:13300}
Junio C Hamanoeef01fe2010-12-13 08:31:58301td.hdlist2 {
Junio C Hamanoe90436a2007-04-22 07:22:13302 vertical-align: top;
303}
Junio C Hamanoeef01fe2010-12-13 08:31:58304div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
307}
308
309.comment {
310 background: yellow;
311}
Junio C Hamanoe90436a2007-04-22 07:22:13312
313@media print {
314 div#footer-badges { display: none; }
315}
Junio C Hamanoba4b9282008-07-06 05:20:31316
317div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
324}
325
326div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
329}
330div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
333}
334div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
337}
338div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
341}
Junio C Hamanoeef01fe2010-12-13 08:31:58342/* Overrides for manpage documents */
343h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
348}
349h2 {
350 border-style: none;
351}
352div.sectionbody {
353 margin-left: 5%;
354}
355
356@media print {
357 div#toc { display: none; }
358}
359
Junio C Hamanoe90436a2007-04-22 07:22:13360/* Workarounds for IE6's broken and incomplete CSS2. */
361
362div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
366}
367div.sidebar-title, div.image-title {
Junio C Hamanoeef01fe2010-12-13 08:31:58368 color: #527bbd;
Junio C Hamanoe90436a2007-04-22 07:22:13369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
373}
374
375div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
379}
380
Junio C Hamanoeef01fe2010-12-13 08:31:58381div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
384}
385
386div.verseblock-content {
387 white-space: pre;
388}
389div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
Junio C Hamanoe90436a2007-04-22 07:22:13392}
393
394div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
397}
Junio C Hamanoba4b9282008-07-06 05:20:31398
399/* IE6 sets dynamically generated links as visited. */
400div#toc a:visited { color: blue; }
Junio C Hamanoe90436a2007-04-22 07:22:13401</style>
Junio C Hamanoe90436a2007-04-22 07:22:13402</head>
403<body>
404<div id="header">
405<h1>
406gitattributes(5) Manual Page
407</h1>
408<h2>NAME</h2>
409<div class="sectionbody">
410<p>gitattributes -
411 defining attributes per path
412</p>
413</div>
414</div>
Junio C Hamanoeef01fe2010-12-13 08:31:58415<h2 id="_synopsis">SYNOPSIS</h2>
Junio C Hamanoe90436a2007-04-22 07:22:13416<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:58417<div class="paragraph"><p>$GIT_DIR/info/attributes, .gitattributes</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:13418</div>
Junio C Hamanoba4b9282008-07-06 05:20:31419<h2 id="_description">DESCRIPTION</h2>
Junio C Hamanoe90436a2007-04-22 07:22:13420<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:58421<div class="paragraph"><p>A <tt>gitattributes</tt> file is a simple text file that gives
Junio C Hamanoba4b9282008-07-06 05:20:31422<tt>attributes</tt> to pathnames.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58423<div class="paragraph"><p>Each line in <tt>gitattributes</tt> file is of form:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:13424<div class="literalblock">
425<div class="content">
Junio C Hamanod533bdb2009-02-25 09:56:58426<pre><tt>pattern attr1 attr2 ...</tt></pre>
Junio C Hamanoe90436a2007-04-22 07:22:13427</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58428<div class="paragraph"><p>That is, a pattern followed by an attributes list,
Junio C Hamanod533bdb2009-02-25 09:56:58429separated by whitespaces. When the pattern matches the
Junio C Hamanoe90436a2007-04-22 07:22:13430path in question, the attributes listed on the line are given to
Junio C Hamanoba4b9282008-07-06 05:20:31431the path.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58432<div class="paragraph"><p>Each attribute can be in one of these states for a given path:</p></div>
433<div class="dlist"><dl>
434<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13435Set
436</dt>
437<dd>
438<p>
439 The path has the attribute with special value "true";
440 this is specified by listing only the name of the
441 attribute in the attribute list.
442</p>
443</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58444<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13445Unset
446</dt>
447<dd>
448<p>
449 The path has the attribute with special value "false";
450 this is specified by listing the name of the attribute
451 prefixed with a dash <tt>-</tt> in the attribute list.
452</p>
453</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58454<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13455Set to a value
456</dt>
457<dd>
458<p>
459 The path has the attribute with specified string value;
460 this is specified by listing the name of the attribute
461 followed by an equal sign <tt>=</tt> and its value in the
462 attribute list.
463</p>
464</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58465<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13466Unspecified
467</dt>
468<dd>
469<p>
Junio C Hamanod533bdb2009-02-25 09:56:58470 No pattern matches the path, and nothing says if
Junio C Hamano22572e72007-04-25 05:59:25471 the path has or does not have the attribute, the
472 attribute for the path is said to be Unspecified.
Junio C Hamanoe90436a2007-04-22 07:22:13473</p>
474</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31475</dl></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58476<div class="paragraph"><p>When more than one pattern matches the path, a later line
Junio C Hamano22572e72007-04-25 05:59:25477overrides an earlier line. This overriding is done per
Junio C Hamanod533bdb2009-02-25 09:56:58478attribute. The rules how the pattern matches paths are the
479same as in <tt>.gitignore</tt> files; see <a href="gitignore.html">gitignore(5)</a>.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58480<div class="paragraph"><p>When deciding what attributes are assigned to a path, git
Junio C Hamanoe90436a2007-04-22 07:22:13481consults <tt>$GIT_DIR/info/attributes</tt> file (which has the highest
482precedence), <tt>.gitattributes</tt> file in the same directory as the
Junio C Hamanob4a9ede2009-04-08 07:36:32483path in question, and its parent directories up to the toplevel of the
484work tree (the further the directory that contains <tt>.gitattributes</tt>
Junio C Hamano3b4609d2010-09-30 00:04:34485is from the path in question, the lower its precedence). Finally
486global and system-wide files are considered (they have the lowest
487precedence).</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58488<div class="paragraph"><p>If you wish to affect only a single repository (i.e., to assign
Junio C Hamano3b4609d2010-09-30 00:04:34489attributes to files that are particular to
Junio C Hamanoeef01fe2010-12-13 08:31:58490one user&#8217;s workflow for that repository), then
Junio C Hamano99dc24a2008-03-27 23:49:50491attributes should be placed in the <tt>$GIT_DIR/info/attributes</tt> file.
492Attributes which should be version-controlled and distributed to other
493repositories (i.e., attributes of interest to all users) should go into
Junio C Hamano3b4609d2010-09-30 00:04:34494<tt>.gitattributes</tt> files. Attributes that should affect all repositories
495for a single user should be placed in a file specified by the
496<tt>core.attributesfile</tt> configuration option (see <a href="git-config.html">git-config(1)</a>).
497Attributes for all users on a system should be placed in the
498<tt>$(prefix)/etc/gitattributes</tt> file.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58499<div class="paragraph"><p>Sometimes you would need to override an setting of an attribute
Junio C Hamano86d84362011-08-04 00:21:51500for a path to <tt>Unspecified</tt> state. This can be done by listing
Junio C Hamanoba4b9282008-07-06 05:20:31501the name of the attribute prefixed with an exclamation point <tt>!</tt>.</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:13502</div>
Junio C Hamanoba4b9282008-07-06 05:20:31503<h2 id="_effects">EFFECTS</h2>
Junio C Hamanoe90436a2007-04-22 07:22:13504<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:58505<div class="paragraph"><p>Certain operations by git can be influenced by assigning
Junio C Hamano2a8f6dc2007-07-09 08:48:38506particular attributes to a path. Currently, the following
Junio C Hamanoba4b9282008-07-06 05:20:31507operations are attributes-aware.</p></div>
508<h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3><div style="clear:left"></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58509<div class="paragraph"><p>These attributes affect how the contents stored in the
Junio C Hamanoe90436a2007-04-22 07:22:13510repository are copied to the working tree files when commands
Junio C Hamano1aa40d22010-01-21 17:46:43511such as <em>git checkout</em> and <em>git merge</em> run. They also affect how
Junio C Hamanoe90436a2007-04-22 07:22:13512git stores the contents you prepare in the working tree in the
Junio C Hamano1aa40d22010-01-21 17:46:43513repository upon <em>git add</em> and <em>git commit</em>.</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:55514<h4 id="_tt_text_tt"><tt>text</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58515<div class="paragraph"><p>This attribute enables and controls end-of-line normalization. When a
Junio C Hamanobb88cf42010-06-21 15:23:55516text file is normalized, its line endings are converted to LF in the
517repository. To control what line ending style is used in the working
518directory, use the <tt>eol</tt> attribute for a single file and the
519<tt>core.eol</tt> configuration variable for all text files.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58520<div class="dlist"><dl>
521<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13522Set
523</dt>
524<dd>
525<p>
Junio C Hamanobb88cf42010-06-21 15:23:55526 Setting the <tt>text</tt> attribute on a path enables end-of-line
527 normalization and marks the path as a text file. End-of-line
528 conversion takes place without guessing the content type.
Junio C Hamanoe90436a2007-04-22 07:22:13529</p>
530</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58531<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13532Unset
533</dt>
534<dd>
535<p>
Junio C Hamanobb88cf42010-06-21 15:23:55536 Unsetting the <tt>text</tt> attribute on a path tells git not to
Junio C Hamanofcb740a2008-08-31 06:32:05537 attempt any end-of-line conversion upon checkin or checkout.
Junio C Hamanoe90436a2007-04-22 07:22:13538</p>
539</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58540<dt class="hdlist1">
Junio C Hamanobb88cf42010-06-21 15:23:55541Set to string value "auto"
542</dt>
543<dd>
544<p>
545 When <tt>text</tt> is set to "auto", the path is marked for automatic
546 end-of-line normalization. If git decides that the content is
547 text, its line endings are normalized to LF on checkin.
548</p>
549</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58550<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13551Unspecified
552</dt>
553<dd>
554<p>
Junio C Hamanobb88cf42010-06-21 15:23:55555 If the <tt>text</tt> attribute is unspecified, git uses the
556 <tt>core.autocrlf</tt> configuration variable to determine if the
557 file should be converted.
Junio C Hamanoe90436a2007-04-22 07:22:13558</p>
559</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31560</dl></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58561<div class="paragraph"><p>Any other value causes git to act as if <tt>text</tt> has been left
Junio C Hamanobb88cf42010-06-21 15:23:55562unspecified.</p></div>
563<h4 id="_tt_eol_tt"><tt>eol</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58564<div class="paragraph"><p>This attribute sets a specific line-ending style to be used in the
Junio C Hamanobb88cf42010-06-21 15:23:55565working directory. It enables end-of-line normalization without any
566content checks, effectively setting the <tt>text</tt> attribute.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58567<div class="dlist"><dl>
568<dt class="hdlist1">
Junio C Hamanobb88cf42010-06-21 15:23:55569Set to string value "crlf"
570</dt>
571<dd>
572<p>
573 This setting forces git to normalize line endings for this
574 file on checkin and convert them to CRLF when the file is
575 checked out.
576</p>
577</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58578<dt class="hdlist1">
Junio C Hamanobb88cf42010-06-21 15:23:55579Set to string value "lf"
580</dt>
581<dd>
582<p>
583 This setting forces git to normalize line endings to LF on
584 checkin and prevents conversion to CRLF when the file is
585 checked out.
586</p>
587</dd>
588</dl></div>
589<h4 id="_backwards_compatibility_with_tt_crlf_tt_attribute">Backwards compatibility with <tt>crlf</tt> attribute</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58590<div class="paragraph"><p>For backwards compatibility, the <tt>crlf</tt> attribute is interpreted as
Junio C Hamanobb88cf42010-06-21 15:23:55591follows:</p></div>
592<div class="listingblock">
593<div class="content">
594<pre><tt>crlf text
595-crlf -text
596crlf=input eol=lf</tt></pre>
597</div></div>
598<h4 id="_end_of_line_conversion">End-of-line conversion</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58599<div class="paragraph"><p>While git normally leaves file contents alone, it can be configured to
Junio C Hamanobb88cf42010-06-21 15:23:55600normalize line endings to LF in the repository and, optionally, to
601convert them to CRLF when files are checked out.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58602<div class="paragraph"><p>Here is an example that will make git normalize .txt, .vcproj and .sh
Junio C Hamanobb88cf42010-06-21 15:23:55603files, ensure that .vcproj files have CRLF and .sh files have LF in
604the working directory, and prevent .jpg files from being normalized
605regardless of their content.</p></div>
606<div class="listingblock">
607<div class="content">
608<pre><tt>*.txt text
609*.vcproj eol=crlf
610*.sh eol=lf
611*.jpg -text</tt></pre>
612</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58613<div class="paragraph"><p>Other source code management systems normalize all text files in their
Junio C Hamanobb88cf42010-06-21 15:23:55614repositories, and there are two ways to enable similar automatic
615normalization in git.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58616<div class="paragraph"><p>If you simply want to have CRLF line endings in your working directory
Junio C Hamanobb88cf42010-06-21 15:23:55617regardless of the repository you are working with, you can set the
618config variable "core.autocrlf" without changing any attributes.</p></div>
619<div class="listingblock">
620<div class="content">
621<pre><tt>[core]
622 autocrlf = true</tt></pre>
623</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58624<div class="paragraph"><p>This does not force normalization of all text files, but does ensure
Junio C Hamanobb88cf42010-06-21 15:23:55625that text files that you introduce to the repository have their line
626endings normalized to LF when they are added, and that files that are
627already normalized in the repository stay normalized.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58628<div class="paragraph"><p>If you want to interoperate with a source code management system that
Junio C Hamanobb88cf42010-06-21 15:23:55629enforces end-of-line normalization, or you simply want all text files
630in your repository to be normalized, you should instead set the <tt>text</tt>
Junio C Hamanoeef01fe2010-12-13 08:31:58631attribute to "auto" for <em>all</em> files.</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:55632<div class="listingblock">
633<div class="content">
634<pre><tt>* text=auto</tt></pre>
635</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58636<div class="paragraph"><p>This ensures that all files that git considers to be text will have
Junio C Hamanobb88cf42010-06-21 15:23:55637normalized (LF) line endings in the repository. The <tt>core.eol</tt>
638configuration variable controls which line endings git will use for
639normalized files in your working directory; the default is to use the
640native line ending for your platform, or CRLF if <tt>core.autocrlf</tt> is
641set.</p></div>
642<div class="admonitionblock">
643<table><tr>
644<td class="icon">
645<div class="title">Note</div>
646</td>
647<td class="content">When <tt>text=auto</tt> normalization is enabled in an existing
648repository, any text files containing CRLFs should be normalized. If
649they are not they will be normalized the next time someone tries to
650change them, causing unfortunate misattribution. From a clean working
651directory:</td>
652</tr></table>
653</div>
654<div class="listingblock">
655<div class="content">
656<pre><tt>$ echo "* text=auto" &gt;&gt;.gitattributes
657$ rm .git/index # Remove the index to force git to
658$ git reset # re-scan the working directory
659$ git status # Show files that will be normalized
660$ git add -u
661$ git add .gitattributes
662$ git commit -m "Introduce end-of-line normalization"</tt></pre>
663</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58664<div class="paragraph"><p>If any files that should not be normalized show up in <em>git status</em>,
Junio C Hamanobb88cf42010-06-21 15:23:55665unset their <tt>text</tt> attribute before running <em>git add -u</em>.</p></div>
666<div class="listingblock">
667<div class="content">
668<pre><tt>manual.pdf -text</tt></pre>
669</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58670<div class="paragraph"><p>Conversely, text files that git does not detect can have normalization
Junio C Hamanobb88cf42010-06-21 15:23:55671enabled manually.</p></div>
672<div class="listingblock">
673<div class="content">
674<pre><tt>weirdchars.txt text</tt></pre>
675</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58676<div class="paragraph"><p>If <tt>core.safecrlf</tt> is set to "true" or "warn", git verifies if
Junio C Hamano26e590a2008-02-17 03:53:51677the conversion is reversible for the current setting of
678<tt>core.autocrlf</tt>. For "true", git rejects irreversible
679conversions; for "warn", git only prints a warning but accepts
680an irreversible conversion. The safety triggers to prevent such
681a conversion done to the files in the work tree, but there are a
Junio C Hamanoba4b9282008-07-06 05:20:31682few exceptions. Even though&#8230;</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58683<div class="ulist"><ul>
Junio C Hamano26e590a2008-02-17 03:53:51684<li>
685<p>
Junio C Hamano1aa40d22010-01-21 17:46:43686<em>git add</em> itself does not touch the files in the work tree, the
Junio C Hamano26e590a2008-02-17 03:53:51687 next checkout would, so the safety triggers;
688</p>
689</li>
690<li>
691<p>
Junio C Hamano1aa40d22010-01-21 17:46:43692<em>git apply</em> to update a text file with a patch does touch the files
Junio C Hamano26e590a2008-02-17 03:53:51693 in the work tree, but the operation is about text files and CRLF
694 conversion is about fixing the line ending inconsistencies, so the
695 safety does not trigger;
696</p>
697</li>
698<li>
699<p>
Junio C Hamano1aa40d22010-01-21 17:46:43700<em>git diff</em> itself does not touch the files in the work tree, it is
701 often run to inspect the changes you intend to next <em>git add</em>. To
Junio C Hamano26e590a2008-02-17 03:53:51702 catch potential problems early, safety triggers.
703</p>
704</li>
Junio C Hamanoba4b9282008-07-06 05:20:31705</ul></div>
706<h4 id="_tt_ident_tt"><tt>ident</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58707<div class="paragraph"><p>When the attribute <tt>ident</tt> is set for a path, git replaces
Junio C Hamano6f1bbb72008-10-31 11:32:55708<tt>$Id$</tt> in the blob object with <tt>$Id:</tt>, followed by the
Junio C Hamano469d60e2007-04-29 18:30:3470940-character hexadecimal blob object name, followed by a dollar
710sign <tt>$</tt> upon checkout. Any byte sequence that begins with
Junio C Hamano0430e3a2007-05-15 03:13:17711<tt>$Id:</tt> and ends with <tt>$</tt> in the worktree file is replaced
Junio C Hamanoba4b9282008-07-06 05:20:31712with <tt>$Id$</tt> upon check-in.</p></div>
713<h4 id="_tt_filter_tt"><tt>filter</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58714<div class="paragraph"><p>A <tt>filter</tt> attribute can be set to a string value that names a
Junio C Hamanoba4b9282008-07-06 05:20:31715filter driver specified in the configuration.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58716<div class="paragraph"><p>A filter driver consists of a <tt>clean</tt> command and a <tt>smudge</tt>
Junio C Hamano469d60e2007-04-29 18:30:34717command, either of which can be left unspecified. Upon
Junio C Hamano361c1332007-11-14 12:17:22718checkout, when the <tt>smudge</tt> command is specified, the command is
719fed the blob object from its standard input, and its standard
720output is used to update the worktree file. Similarly, the
721<tt>clean</tt> command is used to convert the contents of worktree file
Junio C Hamanoba4b9282008-07-06 05:20:31722upon checkin.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58723<div class="paragraph"><p>A missing filter driver definition in the config is not an error
Junio C Hamanoba4b9282008-07-06 05:20:31724but makes the filter a no-op passthru.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58725<div class="paragraph"><p>The content filtering is done to massage the content into a
Junio C Hamano469d60e2007-04-29 18:30:34726shape that is more convenient for the platform, filesystem, and
Junio C Hamano361c1332007-11-14 12:17:22727the user to use. The key phrase here is "more convenient" and not
Junio C Hamano4fd58d42007-09-30 00:51:14728"turning something unusable into usable". In other words, the
729intent is that if someone unsets the filter driver definition,
730or does not have the appropriate filter program, the project
Junio C Hamanoba4b9282008-07-06 05:20:31731should still be usable.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58732<div class="paragraph"><p>For example, in .gitattributes, you would assign the <tt>filter</tt>
Junio C Hamano6a548ef2009-12-17 00:16:20733attribute for paths.</p></div>
734<div class="listingblock">
735<div class="content">
736<pre><tt>*.c filter=indent</tt></pre>
737</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58738<div class="paragraph"><p>Then you would define a "filter.indent.clean" and "filter.indent.smudge"
Junio C Hamano6a548ef2009-12-17 00:16:20739configuration in your .git/config to specify a pair of commands to
740modify the contents of C programs when the source files are checked
741in ("clean" is run) and checked out (no change is made because the
742command is "cat").</p></div>
743<div class="listingblock">
744<div class="content">
745<pre><tt>[filter "indent"]
746 clean = indent
747 smudge = cat</tt></pre>
748</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58749<div class="paragraph"><p>For best results, <tt>clean</tt> should not alter its output further if it is
750run twice ("clean&#8594;clean" should be equivalent to "clean"), and
Junio C Hamano2db3e752010-09-03 21:33:06751multiple <tt>smudge</tt> commands should not alter <tt>clean</tt>'s output
Junio C Hamanoeef01fe2010-12-13 08:31:58752("smudge&#8594;smudge&#8594;clean" should be equivalent to "clean"). See the
Junio C Hamano2db3e752010-09-03 21:33:06753section on merging below.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58754<div class="paragraph"><p>The "indent" filter is well-behaved in this regard: it will not modify
Junio C Hamano2db3e752010-09-03 21:33:06755input that is already correctly indented. In this case, the lack of a
Junio C Hamanoeef01fe2010-12-13 08:31:58756smudge filter means that the clean filter <em>must</em> accept its own output
Junio C Hamano2db3e752010-09-03 21:33:06757without modifying it.</p></div>
Junio C Hamanoe0552e42011-01-06 00:34:47758<div class="paragraph"><p>Sequence "%f" on the filter command line is replaced with the name of
759the file the filter is working on. A filter might use this in keyword
760substitution. For example:</p></div>
761<div class="listingblock">
762<div class="content">
763<pre><tt>[filter "p4"]
764 clean = git-p4-filter --clean %f
765 smudge = git-p4-filter --smudge %f</tt></pre>
766</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31767<h4 id="_interaction_between_checkin_checkout_attributes">Interaction between checkin/checkout attributes</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58768<div class="paragraph"><p>In the check-in codepath, the worktree file is first converted
Junio C Hamano469d60e2007-04-29 18:30:34769with <tt>filter</tt> driver (if specified and corresponding driver
770defined), then the result is processed with <tt>ident</tt> (if
Junio C Hamanobb88cf42010-06-21 15:23:55771specified), and then finally with <tt>text</tt> (again, if specified
Junio C Hamanoba4b9282008-07-06 05:20:31772and applicable).</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58773<div class="paragraph"><p>In the check-out codepath, the blob content is first converted
Junio C Hamanobb88cf42010-06-21 15:23:55774with <tt>text</tt>, and then <tt>ident</tt> and fed to <tt>filter</tt>.</p></div>
Junio C Hamano2db3e752010-09-03 21:33:06775<h4 id="_merging_branches_with_differing_checkin_checkout_attributes">Merging branches with differing checkin/checkout attributes</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58776<div class="paragraph"><p>If you have added attributes to a file that cause the canonical
Junio C Hamano2db3e752010-09-03 21:33:06777repository format for that file to change, such as adding a
778clean/smudge filter or text/eol/ident attributes, merging anything
779where the attribute is not in place would normally cause merge
780conflicts.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58781<div class="paragraph"><p>To prevent these unnecessary merge conflicts, git can be told to run a
Junio C Hamano2db3e752010-09-03 21:33:06782virtual check-out and check-in of all three stages of a file when
783resolving a three-way merge by setting the <tt>merge.renormalize</tt>
784configuration variable. This prevents changes caused by check-in
785conversion from causing spurious merge conflicts when a converted file
786is merged with an unconverted file.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58787<div class="paragraph"><p>As long as a "smudge&#8594;clean" results in the same output as a "clean"
Junio C Hamano2db3e752010-09-03 21:33:06788even on files that are already smudged, this strategy will
789automatically resolve all filter-related conflicts. Filters that do
790not act in this way may cause additional merge conflicts that must be
791resolved manually.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31792<h3 id="_generating_diff_text">Generating diff text</h3><div style="clear:left"></div>
Junio C Hamanof7e47ee2008-11-02 18:16:45793<h4 id="_tt_diff_tt"><tt>diff</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58794<div class="paragraph"><p>The attribute <tt>diff</tt> affects how <em>git</em> generates diffs for particular
Junio C Hamano28363492008-11-14 08:26:31795files. It can tell git whether to generate a textual patch for the path
796or to treat the path as a binary file. It can also affect what line is
797shown on the hunk header <tt>@@ -k,l +n,m @@</tt> line, tell git to use an
798external command to generate the diff, or ask git to convert binary
799files to a text format before generating the diff.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58800<div class="dlist"><dl>
801<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13802Set
803</dt>
804<dd>
805<p>
806 A path to which the <tt>diff</tt> attribute is set is treated
807 as text, even when they contain byte values that
808 normally never appear in text files, such as NUL.
809</p>
810</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58811<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13812Unset
813</dt>
814<dd>
815<p>
816 A path to which the <tt>diff</tt> attribute is unset will
Junio C Hamano28363492008-11-14 08:26:31817 generate <tt>Binary files differ</tt> (or a binary patch, if
818 binary patches are enabled).
Junio C Hamanoe90436a2007-04-22 07:22:13819</p>
820</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58821<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13822Unspecified
823</dt>
824<dd>
825<p>
826 A path to which the <tt>diff</tt> attribute is unspecified
827 first gets its contents inspected, and if it looks like
828 text, it is treated as text. Otherwise it would
829 generate <tt>Binary files differ</tt>.
830</p>
831</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58832<dt class="hdlist1">
Junio C Hamano9db95ca2007-04-23 07:27:05833String
834</dt>
835<dd>
836<p>
Junio C Hamano28363492008-11-14 08:26:31837 Diff is shown using the specified diff driver. Each driver may
838 specify one or more options, as described in the following
839 section. The options for the diff driver "foo" are defined
840 by the configuration variables in the "diff.foo" section of the
841 git config file.
Junio C Hamano9db95ca2007-04-23 07:27:05842</p>
843</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31844</dl></div>
Junio C Hamano28363492008-11-14 08:26:31845<h4 id="_defining_an_external_diff_driver">Defining an external diff driver</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58846<div class="paragraph"><p>The definition of a diff driver is done in <tt>gitconfig</tt>, not
Junio C Hamano9db95ca2007-04-23 07:27:05847<tt>gitattributes</tt> file, so strictly speaking this manual page is a
Junio C Hamanoba4b9282008-07-06 05:20:31848wrong place to talk about it. However&#8230;</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58849<div class="paragraph"><p>To define an external diff driver <tt>jcdiff</tt>, add a section to your
Junio C Hamanoba4b9282008-07-06 05:20:31850<tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
Junio C Hamano9db95ca2007-04-23 07:27:05851<div class="listingblock">
852<div class="content">
853<pre><tt>[diff "jcdiff"]
854 command = j-c-diff</tt></pre>
855</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58856<div class="paragraph"><p>When git needs to show you a diff for the path with <tt>diff</tt>
Junio C Hamano9db95ca2007-04-23 07:27:05857attribute set to <tt>jcdiff</tt>, it calls the command you specified
858with the above configuration, i.e. <tt>j-c-diff</tt>, with 7
859parameters, just like <tt>GIT_EXTERNAL_DIFF</tt> program is called.
Junio C Hamanoba4b9282008-07-06 05:20:31860See <a href="git.html">git(1)</a> for details.</p></div>
861<h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58862<div class="paragraph"><p>Each group of changes (called a "hunk") in the textual diff output
Junio C Hamanoba4b9282008-07-06 05:20:31863is prefixed with a line of the form:</p></div>
Junio C Hamano2a8f6dc2007-07-09 08:48:38864<div class="literalblock">
865<div class="content">
866<pre><tt>@@ -k,l +n,m @@ TEXT</tt></pre>
867</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58868<div class="paragraph"><p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line
Junio C Hamano5e4d8de2008-09-19 06:27:02869that begins with an alphabet, an underscore or a dollar sign; this
870matches what GNU <em>diff -p</em> output uses. This default selection however
871is not suited for some contents, and you can use a customized pattern
872to make a selection.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58873<div class="paragraph"><p>First, in .gitattributes, you would assign the <tt>diff</tt> attribute
Junio C Hamanoba4b9282008-07-06 05:20:31874for paths.</p></div>
Junio C Hamano2a8f6dc2007-07-09 08:48:38875<div class="listingblock">
876<div class="content">
877<pre><tt>*.tex diff=tex</tt></pre>
878</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58879<div class="paragraph"><p>Then, you would define a "diff.tex.xfuncname" configuration to
Junio C Hamano2a8f6dc2007-07-09 08:48:38880specify a regular expression that matches a line that you would
Junio C Hamano3bd66e92009-04-18 06:17:56881want to appear as the hunk header "TEXT". Add a section to your
882<tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
Junio C Hamano2a8f6dc2007-07-09 08:48:38883<div class="listingblock">
884<div class="content">
885<pre><tt>[diff "tex"]
Junio C Hamanoa476efa2008-10-10 15:31:42886 xfuncname = "^(\\\\(sub)*section\\{.*)$"</tt></pre>
Junio C Hamano2a8f6dc2007-07-09 08:48:38887</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58888<div class="paragraph"><p>Note. A single level of backslashes are eaten by the
Junio C Hamano2a8f6dc2007-07-09 08:48:38889configuration file parser, so you would need to double the
890backslashes; the pattern above picks a line that begins with a
Junio C Hamanoa6387422007-08-25 03:54:27891backslash, and zero or more occurrences of <tt>sub</tt> followed by
Junio C Hamanoba4b9282008-07-06 05:20:31892<tt>section</tt> followed by open brace, to the end of line.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58893<div class="paragraph"><p>There are a few built-in patterns to make this easier, and <tt>tex</tt>
Junio C Hamano2a8f6dc2007-07-09 08:48:38894is one of them, so you do not have to write the above in your
895configuration file (you still need to enable this with the
Junio C Hamanoa76cb0d2008-08-13 20:04:10896attribute mechanism, via <tt>.gitattributes</tt>). The following built in
897patterns are available:</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58898<div class="ulist"><ul>
Junio C Hamanoa76cb0d2008-08-13 20:04:10899<li>
900<p>
901<tt>bibtex</tt> suitable for files with BibTeX coded references.
902</p>
903</li>
904<li>
905<p>
Junio C Hamano20d47e32009-01-26 06:36:02906<tt>cpp</tt> suitable for source code in the C and C++ languages.
907</p>
908</li>
909<li>
910<p>
Junio C Hamano53ba6d02010-08-22 07:25:12911<tt>csharp</tt> suitable for source code in the C# language.
912</p>
913</li>
914<li>
915<p>
Junio C Hamano3b4609d2010-09-30 00:04:34916<tt>fortran</tt> suitable for source code in the Fortran language.
917</p>
918</li>
919<li>
920<p>
Junio C Hamanof24b8062008-09-09 01:34:39921<tt>html</tt> suitable for HTML/XHTML documents.
922</p>
923</li>
924<li>
925<p>
Junio C Hamano675570c2008-09-13 06:07:28926<tt>java</tt> suitable for source code in the Java language.
Junio C Hamanoa76cb0d2008-08-13 20:04:10927</p>
928</li>
929<li>
930<p>
Junio C Hamanoa476efa2008-10-10 15:31:42931<tt>objc</tt> suitable for source code in the Objective-C language.
932</p>
933</li>
934<li>
935<p>
Junio C Hamanoa76cb0d2008-08-13 20:04:10936<tt>pascal</tt> suitable for source code in the Pascal/Delphi language.
937</p>
938</li>
939<li>
940<p>
Junio C Hamano9b6fafe2011-01-14 00:43:22941<tt>perl</tt> suitable for source code in the Perl language.
942</p>
943</li>
944<li>
945<p>
Junio C Hamanof24b8062008-09-09 01:34:39946<tt>php</tt> suitable for source code in the PHP language.
947</p>
948</li>
949<li>
950<p>
Junio C Hamano3f2f6e52008-08-21 10:34:22951<tt>python</tt> suitable for source code in the Python language.
952</p>
953</li>
954<li>
955<p>
Junio C Hamanoa76cb0d2008-08-13 20:04:10956<tt>ruby</tt> suitable for source code in the Ruby language.
957</p>
958</li>
959<li>
960<p>
961<tt>tex</tt> suitable for source code for LaTeX documents.
962</p>
963</li>
964</ul></div>
Junio C Hamano20d47e32009-01-26 06:36:02965<h4 id="_customizing_word_diff">Customizing word diff</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58966<div class="paragraph"><p>You can customize the rules that <tt>git diff --word-diff</tt> uses to
Junio C Hamano20d47e32009-01-26 06:36:02967split words in a line, by specifying an appropriate regular expression
968in the "diff.*.wordRegex" configuration variable. For example, in TeX
969a backslash followed by a sequence of letters forms a command, but
970several such commands can be run together without intervening
Junio C Hamano3bd66e92009-04-18 06:17:56971whitespace. To separate them, use a regular expression in your
972<tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
Junio C Hamano20d47e32009-01-26 06:36:02973<div class="listingblock">
974<div class="content">
975<pre><tt>[diff "tex"]
976 wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</tt></pre>
977</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58978<div class="paragraph"><p>A built-in pattern is provided for all languages listed in the
Junio C Hamano20d47e32009-01-26 06:36:02979previous section.</p></div>
Junio C Hamano28363492008-11-14 08:26:31980<h4 id="_performing_text_diffs_of_binary_files">Performing text diffs of binary files</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58981<div class="paragraph"><p>Sometimes it is desirable to see the diff of a text-converted
Junio C Hamano28363492008-11-14 08:26:31982version of some binary files. For example, a word processor
983document can be converted to an ASCII text representation, and
984the diff of the text shown. Even though this conversion loses
985some information, the resulting diff is useful for human
986viewing (but cannot be applied directly).</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58987<div class="paragraph"><p>The <tt>textconv</tt> config option is used to define a program for
Junio C Hamano28363492008-11-14 08:26:31988performing such a conversion. The program should take a single
989argument, the name of a file to convert, and produce the
990resulting text on stdout.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58991<div class="paragraph"><p>For example, to show the diff of the exif information of a
Junio C Hamano28363492008-11-14 08:26:31992file instead of the binary information (assuming you have the
Junio C Hamano3bd66e92009-04-18 06:17:56993exif tool installed), add the following section to your
994<tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file):</p></div>
Junio C Hamano28363492008-11-14 08:26:31995<div class="listingblock">
996<div class="content">
997<pre><tt>[diff "jpg"]
998 textconv = exif</tt></pre>
999</div></div>
1000<div class="admonitionblock">
1001<table><tr>
1002<td class="icon">
1003<div class="title">Note</div>
1004</td>
1005<td class="content">The text conversion is generally a one-way conversion;
1006in this example, we lose the actual image contents and focus
1007just on the text data. This means that diffs generated by
Junio C Hamanoeef01fe2010-12-13 08:31:581008textconv are <em>not</em> suitable for applying. For this reason,
Junio C Hamano28363492008-11-14 08:26:311009only <tt>git diff</tt> and the <tt>git log</tt> family of commands (i.e.,
1010log, whatchanged, show) will perform text conversion. <tt>git
1011format-patch</tt> will never generate this output. If you want to
1012send somebody a text-converted diff of a binary file (e.g.,
1013because it quickly conveys the changes you have made), you
Junio C Hamanoeef01fe2010-12-13 08:31:581014should generate it separately and send it as a comment <em>in
1015addition to</em> the usual binary diff that you might send.</td>
Junio C Hamano28363492008-11-14 08:26:311016</tr></table>
1017</div>
Junio C Hamanoeef01fe2010-12-13 08:31:581018<div class="paragraph"><p>Because text conversion can be slow, especially when doing a
Junio C Hamanocb39aea2010-05-09 07:24:481019large number of them with <tt>git log -p</tt>, git provides a mechanism
1020to cache the output and use it in future diffs. To enable
Junio C Hamanoeef01fe2010-12-13 08:31:581021caching, set the "cachetextconv" variable in your diff driver&#8217;s
Junio C Hamanocb39aea2010-05-09 07:24:481022config. For example:</p></div>
1023<div class="listingblock">
1024<div class="content">
1025<pre><tt>[diff "jpg"]
1026 textconv = exif
1027 cachetextconv = true</tt></pre>
1028</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581029<div class="paragraph"><p>This will cache the result of running "exif" on each blob
Junio C Hamanocb39aea2010-05-09 07:24:481030indefinitely. If you change the textconv config variable for a
1031diff driver, git will automatically invalidate the cache entries
1032and re-run the textconv filter. If you want to invalidate the
1033cache manually (e.g., because your version of "exif" was updated
1034and now produces better output), you can remove the cache
1035manually with <tt>git update-ref -d refs/notes/textconv/jpg</tt> (where
1036"jpg" is the name of the diff driver, as in the example above).</p></div>
Junio C Hamanof93530e2011-05-25 23:59:591037<h4 id="_choosing_textconv_versus_external_diff">Choosing textconv versus external diff</h4>
1038<div class="paragraph"><p>If you want to show differences between binary or specially-formatted
1039blobs in your repository, you can choose to use either an external diff
1040command, or to use textconv to convert them to a diff-able text format.
1041Which method you choose depends on your exact situation.</p></div>
1042<div class="paragraph"><p>The advantage of using an external diff command is flexibility. You are
1043not bound to find line-oriented changes, nor is it necessary for the
1044output to resemble unified diff. You are free to locate and report
1045changes in the most appropriate way for your data format.</p></div>
1046<div class="paragraph"><p>A textconv, by comparison, is much more limiting. You provide a
1047transformation of the data into a line-oriented text format, and git
1048uses its regular diff tools to generate the output. There are several
1049advantages to choosing this method:</p></div>
1050<div class="olist arabic"><ol class="arabic">
1051<li>
1052<p>
1053Ease of use. It is often much simpler to write a binary to text
1054 transformation than it is to perform your own diff. In many cases,
1055 existing programs can be used as textconv filters (e.g., exif,
1056 odt2txt).
1057</p>
1058</li>
1059<li>
1060<p>
1061Git diff features. By performing only the transformation step
1062 yourself, you can still utilize many of git&#8217;s diff features,
1063 including colorization, word-diff, and combined diffs for merges.
1064</p>
1065</li>
1066<li>
1067<p>
1068Caching. Textconv caching can speed up repeated diffs, such as those
1069 you might trigger by running <tt>git log -p</tt>.
1070</p>
1071</li>
1072</ol></div>
Junio C Hamano9b6fafe2011-01-14 00:43:221073<h4 id="_marking_files_as_binary">Marking files as binary</h4>
1074<div class="paragraph"><p>Git usually guesses correctly whether a blob contains text or binary
1075data by examining the beginning of the contents. However, sometimes you
1076may want to override its decision, either because a blob contains binary
1077data later in the file, or because the content, while technically
1078composed of text characters, is opaque to a human reader. For example,
1079many postscript files contain only ascii characters, but produce noisy
1080and meaningless diffs.</p></div>
1081<div class="paragraph"><p>The simplest way to mark a file as binary is to unset the diff
1082attribute in the <tt>.gitattributes</tt> file:</p></div>
1083<div class="listingblock">
1084<div class="content">
1085<pre><tt>*.ps -diff</tt></pre>
1086</div></div>
1087<div class="paragraph"><p>This will cause git to generate <tt>Binary files differ</tt> (or a binary
1088patch, if binary patches are enabled) instead of a regular diff.</p></div>
1089<div class="paragraph"><p>However, one may also want to specify other diff driver attributes. For
1090example, you might want to use <tt>textconv</tt> to convert postscript files to
1091an ascii representation for human viewing, but otherwise treat them as
1092binary files. You cannot specify both <tt>-diff</tt> and <tt>diff=ps</tt> attributes.
1093The solution is to use the <tt>diff.*.binary</tt> config option:</p></div>
1094<div class="listingblock">
1095<div class="content">
1096<pre><tt>[diff "ps"]
1097 textconv = ps2ascii
1098 binary = true</tt></pre>
1099</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311100<h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3><div style="clear:left"></div>
Junio C Hamanof7e47ee2008-11-02 18:16:451101<h4 id="_tt_merge_tt"><tt>merge</tt></h4>
Junio C Hamanofa28cb12011-03-19 01:35:351102<div class="paragraph"><p>The attribute <tt>merge</tt> affects how three versions of a file are
Junio C Hamanoe90436a2007-04-22 07:22:131103merged when a file-level merge is necessary during <tt>git merge</tt>,
Junio C Hamano27a128b2009-08-13 01:23:001104and other commands such as <tt>git revert</tt> and <tt>git cherry-pick</tt>.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581105<div class="dlist"><dl>
1106<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131107Set
1108</dt>
1109<dd>
1110<p>
1111 Built-in 3-way merge driver is used to merge the
Junio C Hamanoba4b9282008-07-06 05:20:311112 contents in a way similar to <em>merge</em> command of <tt>RCS</tt>
Junio C Hamanoe90436a2007-04-22 07:22:131113 suite. This is suitable for ordinary text files.
1114</p>
1115</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581116<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131117Unset
1118</dt>
1119<dd>
1120<p>
1121 Take the version from the current branch as the
1122 tentative merge result, and declare that the merge has
Junio C Hamanofa28cb12011-03-19 01:35:351123 conflicts. This is suitable for binary files that do
Junio C Hamanoe90436a2007-04-22 07:22:131124 not have a well-defined merge semantics.
1125</p>
1126</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581127<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131128Unspecified
1129</dt>
1130<dd>
1131<p>
1132 By default, this uses the same built-in 3-way merge
Junio C Hamanofa28cb12011-03-19 01:35:351133 driver as is the case when the <tt>merge</tt> attribute is set.
1134 However, the <tt>merge.default</tt> configuration variable can name
1135 different merge driver to be used with paths for which the
Junio C Hamanoe90436a2007-04-22 07:22:131136 <tt>merge</tt> attribute is unspecified.
1137</p>
1138</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581139<dt class="hdlist1">
Junio C Hamano9db95ca2007-04-23 07:27:051140String
Junio C Hamanoe90436a2007-04-22 07:22:131141</dt>
1142<dd>
1143<p>
1144 3-way merge is performed using the specified custom
1145 merge driver. The built-in 3-way merge driver can be
1146 explicitly specified by asking for "text" driver; the
1147 built-in "take the current branch" driver can be
Junio C Hamano22572e72007-04-25 05:59:251148 requested with "binary".
Junio C Hamanoe90436a2007-04-22 07:22:131149</p>
1150</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311151</dl></div>
1152<h4 id="_built_in_merge_drivers">Built-in merge drivers</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581153<div class="paragraph"><p>There are a few built-in low-level merge drivers defined that
Junio C Hamanoba4b9282008-07-06 05:20:311154can be asked for via the <tt>merge</tt> attribute.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581155<div class="dlist"><dl>
1156<dt class="hdlist1">
Junio C Hamanof556fc22007-12-23 08:16:381157text
1158</dt>
1159<dd>
1160<p>
1161 Usual 3-way file level merge for text files. Conflicted
1162 regions are marked with conflict markers <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt>,
1163 <tt>=======</tt> and <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt>. The version from your branch
1164 appears before the <tt>=======</tt> marker, and the version
1165 from the merged branch appears after the <tt>=======</tt>
1166 marker.
1167</p>
1168</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581169<dt class="hdlist1">
Junio C Hamanof556fc22007-12-23 08:16:381170binary
1171</dt>
1172<dd>
1173<p>
1174 Keep the version from your branch in the work tree, but
1175 leave the path in the conflicted state for the user to
1176 sort out.
1177</p>
1178</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581179<dt class="hdlist1">
Junio C Hamanof556fc22007-12-23 08:16:381180union
1181</dt>
1182<dd>
1183<p>
1184 Run 3-way file level merge for text files, but take
1185 lines from both versions, instead of leaving conflict
1186 markers. This tends to leave the added lines in the
1187 resulting file in random order and the user should
1188 verify the result. Do not use this if you do not
1189 understand the implications.
1190</p>
1191</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311192</dl></div>
1193<h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581194<div class="paragraph"><p>The definition of a merge driver is done in the <tt>.git/config</tt>
Junio C Hamanof556fc22007-12-23 08:16:381195file, not in the <tt>gitattributes</tt> file, so strictly speaking this
Junio C Hamanoba4b9282008-07-06 05:20:311196manual page is a wrong place to talk about it. However&#8230;</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581197<div class="paragraph"><p>To define a custom merge driver <tt>filfre</tt>, add a section to your
Junio C Hamanoba4b9282008-07-06 05:20:311198<tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131199<div class="listingblock">
1200<div class="content">
1201<pre><tt>[merge "filfre"]
1202 name = feel-free merge driver
1203 driver = filfre %O %A %B
1204 recursive = binary</tt></pre>
1205</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581206<div class="paragraph"><p>The <tt>merge.*.name</tt> variable gives the driver a human-readable
Junio C Hamanoba4b9282008-07-06 05:20:311207name.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581208<div class="paragraph"><p>The &#8216;merge.*.driver` variable&#8217;s value is used to construct a
1209command to run to merge ancestor&#8217;s version (<tt>%O</tt>), current
1210version (<tt>%A</tt>) and the other branches&#8217; version (<tt>%B</tt>). These
Junio C Hamanoe90436a2007-04-22 07:22:131211three tokens are replaced with the names of temporary files that
1212hold the contents of these versions when the command line is
Junio C Hamano86660db2010-02-24 01:12:541213built. Additionally, %L will be replaced with the conflict marker
1214size (see below).</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581215<div class="paragraph"><p>The merge driver is expected to leave the result of the merge in
Junio C Hamanoe90436a2007-04-22 07:22:131216the file named with <tt>%A</tt> by overwriting it, and exit with zero
1217status if it managed to merge them cleanly, or non-zero if there
Junio C Hamanoba4b9282008-07-06 05:20:311218were conflicts.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581219<div class="paragraph"><p>The <tt>merge.*.recursive</tt> variable specifies what other merge
Junio C Hamanoe90436a2007-04-22 07:22:131220driver to use when the merge driver is called for an internal
1221merge between common ancestors, when there are more than one.
1222When left unspecified, the driver itself is used for both
Junio C Hamanoba4b9282008-07-06 05:20:311223internal merge and the final merge.</p></div>
Junio C Hamano1aa40d22010-01-21 17:46:431224<h4 id="_tt_conflict_marker_size_tt"><tt>conflict-marker-size</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581225<div class="paragraph"><p>This attribute controls the length of conflict markers left in
Junio C Hamano1aa40d22010-01-21 17:46:431226the work tree file during a conflicted merge. Only setting to
1227the value to a positive integer has any meaningful effect.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581228<div class="paragraph"><p>For example, this line in <tt>.gitattributes</tt> can be used to tell the merge
Junio C Hamano1aa40d22010-01-21 17:46:431229machinery to leave much longer (instead of the usual 7-character-long)
1230conflict markers when merging the file <tt>Documentation/git-merge.txt</tt>
1231results in a conflict.</p></div>
1232<div class="listingblock">
1233<div class="content">
1234<pre><tt>Documentation/git-merge.txt conflict-marker-size=32</tt></pre>
1235</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311236<h3 id="_checking_whitespace_errors">Checking whitespace errors</h3><div style="clear:left"></div>
1237<h4 id="_tt_whitespace_tt"><tt>whitespace</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581238<div class="paragraph"><p>The <tt>core.whitespace</tt> configuration variable allows you to define what
Junio C Hamanoba4b9282008-07-06 05:20:311239<em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in
Junio C Hamano942b35e2007-12-09 10:19:331240the project (See <a href="git-config.html">git-config(1)</a>). This attribute gives you finer
Junio C Hamanoba4b9282008-07-06 05:20:311241control per path.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581242<div class="dlist"><dl>
1243<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331244Set
1245</dt>
1246<dd>
1247<p>
1248 Notice all types of potential whitespace errors known to git.
Junio C Hamanoeef01fe2010-12-13 08:31:581249 The tab width is taken from the value of the <tt>core.whitespace</tt>
1250 configuration variable.
Junio C Hamano942b35e2007-12-09 10:19:331251</p>
1252</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581253<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331254Unset
1255</dt>
1256<dd>
1257<p>
1258 Do not notice anything as error.
1259</p>
1260</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581261<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331262Unspecified
1263</dt>
1264<dd>
1265<p>
Junio C Hamanoeef01fe2010-12-13 08:31:581266 Use the value of the <tt>core.whitespace</tt> configuration variable to
Junio C Hamano942b35e2007-12-09 10:19:331267 decide what to notice as error.
1268</p>
1269</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581270<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331271String
1272</dt>
1273<dd>
1274<p>
1275 Specify a comma separate list of common whitespace problems to
Junio C Hamanoeef01fe2010-12-13 08:31:581276 notice in the same format as the <tt>core.whitespace</tt> configuration
Junio C Hamano942b35e2007-12-09 10:19:331277 variable.
1278</p>
1279</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311280</dl></div>
1281<h3 id="_creating_an_archive">Creating an archive</h3><div style="clear:left"></div>
1282<h4 id="_tt_export_ignore_tt"><tt>export-ignore</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581283<div class="paragraph"><p>Files and directories with the attribute <tt>export-ignore</tt> won&#8217;t be added to
Junio C Hamanoba4b9282008-07-06 05:20:311284archive files.</p></div>
1285<h4 id="_tt_export_subst_tt"><tt>export-subst</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581286<div class="paragraph"><p>If the attribute <tt>export-subst</tt> is set for a file then git will expand
Junio C Hamanoba4b9282008-07-06 05:20:311287several placeholders when adding this file to an archive. The
1288expansion depends on the availability of a commit ID, i.e., if
1289<a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a
1290tag then no replacement will be done. The placeholders are the same
1291as those for the option <tt>--pretty=format:</tt> of <a href="git-log.html">git-log(1)</a>,
1292except that they need to be wrapped like this: <tt>$Format:PLACEHOLDERS$</tt>
1293in the file. E.g. the string <tt>$Format:%H$</tt> will be replaced by the
1294commit hash.</p></div>
Junio C Hamanoa10d8d22009-10-22 03:09:051295<h3 id="_packing_objects">Packing objects</h3><div style="clear:left"></div>
1296<h4 id="_tt_delta_tt"><tt>delta</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581297<div class="paragraph"><p>Delta compression will not be attempted for blobs for paths with the
Junio C Hamanoa10d8d22009-10-22 03:09:051298attribute <tt>delta</tt> set to false.</p></div>
Junio C Hamanod3452a02008-11-15 08:07:551299<h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3><div style="clear:left"></div>
1300<h4 id="_tt_encoding_tt"><tt>encoding</tt></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581301<div class="paragraph"><p>The value of this attribute specifies the character encoding that should
Junio C Hamanod3452a02008-11-15 08:07:551302be used by GUI tools (e.g. <a href="gitk.html">gitk(1)</a> and <a href="git-gui.html">git-gui(1)</a>) to
1303display the contents of the relevant file. Note that due to performance
1304considerations <a href="gitk.html">gitk(1)</a> does not use this attribute unless you
1305manually enable per-file encodings in its options.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581306<div class="paragraph"><p>If this attribute is not set or has an invalid value, the value of the
Junio C Hamanod3452a02008-11-15 08:07:551307<tt>gui.encoding</tt> configuration variable is used instead
1308(See <a href="git-config.html">git-config(1)</a>).</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131309</div>
Junio C Hamano86d84362011-08-04 00:21:511310<h2 id="_using_macro_attributes">USING MACRO ATTRIBUTES</h2>
Junio C Hamanofcb740a2008-08-31 06:32:051311<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:581312<div class="paragraph"><p>You do not want any end-of-line conversions applied to, nor textual diffs
Junio C Hamanofcb740a2008-08-31 06:32:051313produced for, any binary file you track. You would need to specify e.g.</p></div>
1314<div class="listingblock">
1315<div class="content">
Junio C Hamanobb88cf42010-06-21 15:23:551316<pre><tt>*.jpg -text -diff</tt></pre>
Junio C Hamanofcb740a2008-08-31 06:32:051317</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581318<div class="paragraph"><p>but that may become cumbersome, when you have many attributes. Using
Junio C Hamano86d84362011-08-04 00:21:511319macro attributes, you can define an attribute that, when set, also
1320sets or unsets a number of other attributes at the same time. The
1321system knows a built-in macro attribute, <tt>binary</tt>:</p></div>
Junio C Hamanofcb740a2008-08-31 06:32:051322<div class="listingblock">
1323<div class="content">
1324<pre><tt>*.jpg binary</tt></pre>
1325</div></div>
Junio C Hamano86d84362011-08-04 00:21:511326<div class="paragraph"><p>Setting the "binary" attribute also unsets the "text" and "diff"
1327attributes as above. Note that macro attributes can only be "Set",
1328though setting one might have the effect of setting or unsetting other
1329attributes or even returning other attributes to the "Unspecified"
1330state.</p></div>
Junio C Hamanofcb740a2008-08-31 06:32:051331</div>
Junio C Hamano86d84362011-08-04 00:21:511332<h2 id="_defining_macro_attributes">DEFINING MACRO ATTRIBUTES</h2>
Junio C Hamanofcb740a2008-08-31 06:32:051333<div class="sectionbody">
Junio C Hamano86d84362011-08-04 00:21:511334<div class="paragraph"><p>Custom macro attributes can be defined only in the <tt>.gitattributes</tt>
1335file at the toplevel (i.e. not in any subdirectory). The built-in
1336macro attribute "binary" is equivalent to:</p></div>
Junio C Hamanofcb740a2008-08-31 06:32:051337<div class="listingblock">
1338<div class="content">
Junio C Hamanobb88cf42010-06-21 15:23:551339<pre><tt>[attr]binary -diff -text</tt></pre>
Junio C Hamanofcb740a2008-08-31 06:32:051340</div></div>
1341</div>
Junio C Hamanoba4b9282008-07-06 05:20:311342<h2 id="_example">EXAMPLE</h2>
Junio C Hamanoe90436a2007-04-22 07:22:131343<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:581344<div class="paragraph"><p>If you have these three <tt>gitattributes</tt> file:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131345<div class="listingblock">
1346<div class="content">
1347<pre><tt>(in $GIT_DIR/info/attributes)
1348
1349a* foo !bar -baz
1350
1351(in .gitattributes)
1352abc foo bar baz
1353
1354(in t/.gitattributes)
1355ab* merge=filfre
1356abc -foo -bar
1357*.c frotz</tt></pre>
1358</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581359<div class="paragraph"><p>the attributes given to path <tt>t/abc</tt> are computed as follows:</p></div>
1360<div class="olist arabic"><ol class="arabic">
Junio C Hamanoe90436a2007-04-22 07:22:131361<li>
1362<p>
1363By examining <tt>t/.gitattributes</tt> (which is in the same
Junio C Hamanoa6387422007-08-25 03:54:271364 directory as the path in question), git finds that the first
Junio C Hamanoe90436a2007-04-22 07:22:131365 line matches. <tt>merge</tt> attribute is set. It also finds that
1366 the second line matches, and attributes <tt>foo</tt> and <tt>bar</tt>
1367 are unset.
1368</p>
1369</li>
1370<li>
1371<p>
1372Then it examines <tt>.gitattributes</tt> (which is in the parent
1373 directory), and finds that the first line matches, but
1374 <tt>t/.gitattributes</tt> file already decided how <tt>merge</tt>, <tt>foo</tt>
1375 and <tt>bar</tt> attributes should be given to this path, so it
1376 leaves <tt>foo</tt> and <tt>bar</tt> unset. Attribute <tt>baz</tt> is set.
1377</p>
1378</li>
1379<li>
1380<p>
Junio C Hamanobdeff822007-07-30 09:07:171381Finally it examines <tt>$GIT_DIR/info/attributes</tt>. This file
Junio C Hamanoe90436a2007-04-22 07:22:131382 is used to override the in-tree settings. The first line is
1383 a match, and <tt>foo</tt> is set, <tt>bar</tt> is reverted to unspecified
1384 state, and <tt>baz</tt> is unset.
1385</p>
1386</li>
Junio C Hamanoba4b9282008-07-06 05:20:311387</ol></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581388<div class="paragraph"><p>As the result, the attributes assignment to <tt>t/abc</tt> becomes:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131389<div class="listingblock">
1390<div class="content">
1391<pre><tt>foo set to true
1392bar unspecified
1393baz set to false
1394merge set to string value "filfre"
1395frotz unspecified</tt></pre>
1396</div></div>
1397</div>
Junio C Hamanoba4b9282008-07-06 05:20:311398<h2 id="_git">GIT</h2>
Junio C Hamanoe90436a2007-04-22 07:22:131399<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:581400<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131401</div>
1402<div id="footer">
1403<div id="footer-text">
Junio C Hamano86d84362011-08-04 00:21:511404Last updated 2011-08-04 00:21:28 UTC
Junio C Hamanoe90436a2007-04-22 07:22:131405</div>
1406</div>
1407</body>
1408</html>