blob: a4d149d695c5fdf088a9da2e4f3406d8c8f51177 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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 Hamano7e9f6b72006-02-22 10:44:556<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-update-index(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-update-index(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-update-index -
Junio C Hamano7c73c662007-01-19 00:37:50269 Register file contents in the working tree to the index
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano7e9f6b72006-02-22 10:44:55275<div class="verseblock">
276<div class="content"><em>git-update-index</em>
Junio C Hamano1a4e8412005-12-27 08:17:23277 [--add] [--remove | --force-remove] [--replace]
Junio C Hamano46338f52006-05-04 00:46:44278 [--refresh] [-q] [--unmerged] [--ignore-missing]
Junio C Hamano1a4e8412005-12-27 08:17:23279 [--cacheinfo &lt;mode&gt; &lt;object&gt; &lt;file&gt;]*
280 [--chmod=(+|-)x]
Junio C Hamano7e9f6b72006-02-22 10:44:55281 [--assume-unchanged | --no-assume-unchanged]
Junio C Hamano8a0a21e2006-08-24 07:37:45282 [--really-refresh] [--unresolve] [--again | -g]
Junio C Hamano1a4e8412005-12-27 08:17:23283 [--info-only] [--index-info]
284 [-z] [--stdin]
285 [--verbose]
Junio C Hamano7e9f6b72006-02-22 10:44:55286 [--] [&lt;file&gt;]*</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23287</div>
288<h2>DESCRIPTION</h2>
289<div class="sectionbody">
290<p>Modifies the index or directory cache. Each file mentioned is updated
291into the index and any <em>unmerged</em> or <em>needs updating</em> state is
292cleared.</p>
293<p>The way "git-update-index" handles files it is told about can be modified
294using the various options:</p>
295</div>
296<h2>OPTIONS</h2>
297<div class="sectionbody">
298<dl>
299<dt>
300--add
301</dt>
302<dd>
303<p>
304 If a specified file isn't in the index already then it's
305 added.
306 Default behaviour is to ignore new files.
307</p>
308</dd>
309<dt>
310--remove
311</dt>
312<dd>
313<p>
314 If a specified file is in the index but is missing then it's
315 removed.
Junio C Hamano341071d2006-06-04 07:24:48316 Default behavior is to ignore removed file.
Junio C Hamano1a4e8412005-12-27 08:17:23317</p>
318</dd>
319<dt>
320--refresh
321</dt>
322<dd>
323<p>
324 Looks at the current index and checks to see if merges or
325 updates are needed by checking stat() information.
326</p>
327</dd>
328<dt>
329-q
330</dt>
331<dd>
332<p>
333 Quiet. If --refresh finds that the index needs an update, the
334 default behavior is to error out. This option makes
335 git-update-index continue anyway.
336</p>
337</dd>
338<dt>
339--unmerged
340</dt>
341<dd>
342<p>
343 If --refresh finds unmerged changes in the index, the default
344 behavior is to error out. This option makes git-update-index
345 continue anyway.
346</p>
347</dd>
348<dt>
349--ignore-missing
350</dt>
351<dd>
352<p>
353 Ignores missing files during a --refresh
354</p>
355</dd>
356<dt>
357--cacheinfo &lt;mode&gt; &lt;object&gt; &lt;path&gt;
358</dt>
359<dd>
360<p>
361 Directly insert the specified info into the index.
362</p>
363</dd>
364<dt>
365--index-info
366</dt>
367<dd>
368<p>
369 Read index information from stdin.
370</p>
371</dd>
372<dt>
373--chmod=(+|-)x
374</dt>
375<dd>
376<p>
377 Set the execute permissions on the updated files.
378</p>
379</dd>
380<dt>
Junio C Hamano7e9f6b72006-02-22 10:44:55381--assume-unchanged, --no-assume-unchanged
382</dt>
383<dd>
384<p>
385 When these flags are specified, the object name recorded
386 for the paths are not updated. Instead, these options
387 sets and unsets the "assume unchanged" bit for the
388 paths. When the "assume unchanged" bit is on, git stops
389 checking the working tree files for possible
390 modifications, so you need to manually unset the bit to
391 tell git when you change the working tree file. This is
392 sometimes helpful when working with a big project on a
393 filesystem that has very slow lstat(2) system call
394 (e.g. cifs).
395</p>
396</dd>
397<dt>
Junio C Hamano8a0a21e2006-08-24 07:37:45398--again, -g
Junio C Hamano26a57372006-05-10 00:13:40399</dt>
400<dd>
401<p>
402 Runs <tt>git-update-index</tt> itself on the paths whose index
403 entries are different from those from the <tt>HEAD</tt> commit.
404</p>
405</dd>
406<dt>
Junio C Hamano46338f52006-05-04 00:46:44407--unresolve
408</dt>
409<dd>
410<p>
411 Restores the <em>unmerged</em> or <em>needs updating</em> state of a
412 file during a merge if it was cleared by accident.
413</p>
414</dd>
415<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23416--info-only
417</dt>
418<dd>
419<p>
420 Do not create objects in the object database for all
421 &lt;file&gt; arguments that follow this flag; just insert
422 their object IDs into the index.
423</p>
424</dd>
425<dt>
426--force-remove
427</dt>
428<dd>
429<p>
430 Remove the file from the index even when the working directory
431 still has such a file. (Implies --remove.)
432</p>
433</dd>
434<dt>
435--replace
436</dt>
437<dd>
438<p>
439 By default, when a file <tt>path</tt> exists in the index,
440 git-update-index refuses an attempt to add <tt>path/file</tt>.
441 Similarly if a file <tt>path/file</tt> exists, a file <tt>path</tt>
442 cannot be added. With --replace flag, existing entries
443 that conflicts with the entry being added are
444 automatically removed with warning messages.
445</p>
446</dd>
447<dt>
448--stdin
449</dt>
450<dd>
451<p>
452 Instead of taking list of paths from the command line,
453 read list of paths from the standard input. Paths are
454 separated by LF (i.e. one path per line) by default.
455</p>
456</dd>
457<dt>
458--verbose
459</dt>
460<dd>
461<p>
462 Report what is being added and removed from index.
463</p>
464</dd>
465<dt>
466-z
467</dt>
468<dd>
469<p>
470 Only meaningful with <tt>--stdin</tt>; paths are separated with
471 NUL character instead of LF.
472</p>
473</dd>
474<dt>
Junio C Hamano1bb569e2006-05-05 23:14:25475--
Junio C Hamano1a4e8412005-12-27 08:17:23476</dt>
477<dd>
478<p>
479 Do not interpret any more arguments as options.
480</p>
481</dd>
482<dt>
483&lt;file&gt;
484</dt>
485<dd>
486<p>
487 Files to act on.
488 Note that files beginning with <em>.</em> are discarded. This includes
489 <tt>./file</tt> and <tt>dir/./file</tt>. If you don't want this, then use
490 cleaner names.
491 The same applies to directories ending <em>/</em> and paths with <em>//</em>
492</p>
493</dd>
494</dl>
495</div>
496<h2>Using --refresh</h2>
497<div class="sectionbody">
498<p><em>--refresh</em> does not calculate a new sha1 file or bring the index
499up-to-date for mode/content changes. But what it <strong>does</strong> do is to
500"re-match" the stat information of a file with the index, so that you
501can refresh the index for a file that hasn't been changed but where
502the stat entry is out of date.</p>
503<p>For example, you'd want to do this after doing a "git-read-tree", to link
504up the stat index details with the proper files.</p>
505</div>
506<h2>Using --cacheinfo or --info-only</h2>
507<div class="sectionbody">
508<p><em>--cacheinfo</em> is used to register a file that is not in the
509current working directory. This is useful for minimum-checkout
510merging.</p>
511<p>To pretend you have a file with mode and sha1 at path, say:</p>
512<div class="listingblock">
513<div class="content">
514<pre><tt>$ git-update-index --cacheinfo mode sha1 path</tt></pre>
515</div></div>
516<p><em>--info-only</em> is used to register files without placing them in the object
517database. This is useful for status-only repositories.</p>
518<p>Both <em>--cacheinfo</em> and <em>--info-only</em> behave similarly: the index is updated
519but the object database isn't. <em>--cacheinfo</em> is useful when the object is
520in the database but the file isn't available locally. <em>--info-only</em> is
521useful when the file is available, but you do not wish to update the
522object database.</p>
523</div>
524<h2>Using --index-info</h2>
525<div class="sectionbody">
526<p><tt>--index-info</tt> is a more powerful mechanism that lets you feed
527multiple entry definitions from the standard input, and designed
528specifically for scripts. It can take inputs of three formats:</p>
529<ol>
530<li>
531<p>
532mode SP sha1 TAB path
533</p>
534<p>The first format is what "git-apply --index-info"
535reports, and used to reconstruct a partial tree
536that is used for phony merge base tree when falling
537back on 3-way merge.</p>
538</li>
539<li>
540<p>
541mode SP type SP sha1 TAB path
542</p>
543<p>The second format is to stuff git-ls-tree output
544into the index file.</p>
545</li>
546<li>
547<p>
548mode SP sha1 SP stage TAB path
549</p>
550<p>This format is to put higher order stages into the
551index file and matches git-ls-files --stage output.</p>
552</li>
553</ol>
554<p>To place a higher stage entry to the index, the path should
555first be removed by feeding a mode=0 entry for the path, and
556then feeding necessary input lines in the third format.</p>
557<p>For example, starting with this index:</p>
558<div class="listingblock">
559<div class="content">
560<pre><tt>$ git ls-files -s
561100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz</tt></pre>
562</div></div>
563<p>you can feed the following input to <tt>--index-info</tt>:</p>
564<div class="listingblock">
565<div class="content">
566<pre><tt>$ git update-index --index-info
5670 0000000000000000000000000000000000000000 frotz
568100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz
569100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz</tt></pre>
570</div></div>
571<p>The first line of the input feeds 0 as the mode to remove the
572path; the SHA1 does not matter as long as it is well formatted.
573Then the second and third line feeds stage 1 and stage 2 entries
574for that path. After the above, we would end up with this:</p>
575<div class="listingblock">
576<div class="content">
577<pre><tt>$ git ls-files -s
578100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz
579100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz</tt></pre>
580</div></div>
581</div>
Junio C Hamanofb2ead32006-11-13 23:40:59582<h2>Using &#8220;assume unchanged&#8221; bit</h2>
Junio C Hamano7e9f6b72006-02-22 10:44:55583<div class="sectionbody">
584<p>Many operations in git depend on your filesystem to have an
585efficient <tt>lstat(2)</tt> implementation, so that <tt>st_mtime</tt>
586information for working tree files can be cheaply checked to see
587if the file contents have changed from the version recorded in
588the index file. Unfortunately, some filesystems have
589inefficient <tt>lstat(2)</tt>. If your filesystem is one of them, you
590can set "assume unchanged" bit to paths you have not changed to
591cause git not to do this check. Note that setting this bit on a
592path does not mean git will check the contents of the file to
593see if it has changed &#8212; it makes git to omit any checking and
594assume it has <strong>not</strong> changed. When you make changes to working
595tree files, you have to explicitly tell git about it by dropping
596"assume unchanged" bit, either before or after you modify them.</p>
597<p>In order to set "assume unchanged" bit, use <tt>--assume-unchanged</tt>
598option. To unset, use <tt>--no-assume-unchanged</tt>.</p>
599<p>The command looks at <tt>core.ignorestat</tt> configuration variable. When
600this is true, paths updated with <tt>git-update-index paths&#8230;</tt> and
601paths updated with other git commands that update both index and
602working tree (e.g. <tt>git-apply --index</tt>, <tt>git-checkout-index -u</tt>,
603and <tt>git-read-tree -u</tt>) are automatically marked as "assume
604unchanged". Note that "assume unchanged" bit is <strong>not</strong> set if
605<tt>git-update-index --refresh</tt> finds the working tree file matches
606the index (use <tt>git-update-index --really-refresh</tt> if you want
607to mark them as "assume unchanged").</p>
608</div>
Junio C Hamano1a4e8412005-12-27 08:17:23609<h2>Examples</h2>
610<div class="sectionbody">
611<p>To update and refresh only the files already checked out:</p>
612<div class="listingblock">
613<div class="content">
614<pre><tt>$ git-checkout-index -n -f -a &amp;&amp; git-update-index --ignore-missing --refresh</tt></pre>
615</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01616<dl>
617<dt>
618On an inefficient filesystem with <tt>core.ignorestat</tt> set
619</dt>
620<dd>
Junio C Hamano7e9f6b72006-02-22 10:44:55621<div class="listingblock">
622<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01623<pre><tt>$ git update-index --really-refresh <b>(1)</b>
624$ git update-index --no-assume-unchanged foo.c <b>(2)</b>
625$ git diff --name-only <b>(3)</b>
Junio C Hamano7e9f6b72006-02-22 10:44:55626$ edit foo.c
Junio C Hamanoc8d88c22006-04-29 07:02:01627$ git diff --name-only <b>(4)</b>
Junio C Hamano7e9f6b72006-02-22 10:44:55628M foo.c
Junio C Hamanoc8d88c22006-04-29 07:02:01629$ git update-index foo.c <b>(5)</b>
630$ git diff --name-only <b>(6)</b>
Junio C Hamano7e9f6b72006-02-22 10:44:55631$ edit foo.c
Junio C Hamanoc8d88c22006-04-29 07:02:01632$ git diff --name-only <b>(7)</b>
633$ git update-index --no-assume-unchanged foo.c <b>(8)</b>
634$ git diff --name-only <b>(9)</b>
635M foo.c</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55636</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01637<ol>
638<li>
639<p>
640forces lstat(2) to set "assume unchanged" bits for paths that match index.
641</p>
642</li>
643<li>
644<p>
645mark the path to be edited.
646</p>
647</li>
648<li>
649<p>
650this does lstat(2) and finds index matches the path.
651</p>
652</li>
653<li>
654<p>
655this does lstat(2) and finds index does <strong>not</strong> match the path.
656</p>
657</li>
658<li>
659<p>
660registering the new version to index sets "assume unchanged" bit.
661</p>
662</li>
663<li>
664<p>
665and it is assumed unchanged.
666</p>
667</li>
668<li>
669<p>
670even after you edit it.
671</p>
672</li>
673<li>
674<p>
675you can tell about the change after the fact.
676</p>
677</li>
678<li>
679<p>
680now it checks with lstat(2) and finds it has been changed.
681</p>
682</li>
683</ol>
684</dd>
685</dl>
Junio C Hamano1a4e8412005-12-27 08:17:23686</div>
687<h2>Configuration</h2>
688<div class="sectionbody">
689<p>The command honors <tt>core.filemode</tt> configuration variable. If
690your repository is on an filesystem whose executable bits are
Junio C Hamano7ad22dc2007-01-29 02:55:48691unreliable, this should be set to <em>false</em> (see <a href="git-config.html">git-config(1)</a>).
Junio C Hamano1a4e8412005-12-27 08:17:23692This causes the command to ignore differences in file modes recorded
693in the index and the file mode on the filesystem if they differ only on
694executable bit. On such an unfortunate filesystem, you may
695need to use <tt>git-update-index --chmod=</tt>.</p>
Junio C Hamano7e9f6b72006-02-22 10:44:55696<p>The command looks at <tt>core.ignorestat</tt> configuration variable. See
697<em>Using "assume unchanged" bit</em> section above.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23698</div>
699<h2>See Also</h2>
700<div class="sectionbody">
Junio C Hamano7ad22dc2007-01-29 02:55:48701<p><a href="git-config.html">git-config(1)</a></p>
Junio C Hamano1a4e8412005-12-27 08:17:23702</div>
703<h2>Author</h2>
704<div class="sectionbody">
705<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
706</div>
707<h2>Documentation</h2>
708<div class="sectionbody">
709<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
710</div>
711<h2>GIT</h2>
712<div class="sectionbody">
713<p>Part of the <a href="git.html">git(7)</a> suite</p>
714</div>
715<div id="footer">
716<div id="footer-text">
Junio C Hamano7ad22dc2007-01-29 02:55:48717Last updated 29-Jan-2007 02:55:12 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23718</div>
719</div>
720</body>
721</html>