blob: 2038b4900bc2cc1a4af1a18a6da5e17203f1d31d [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>
Junio C Hamano3d30fd52007-05-08 00:32:53293<p>See also <a href="git-add.html">git-add(1)</a> for a more user-friendly way to do some of
294the most common operations on the index.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23295<p>The way "git-update-index" handles files it is told about can be modified
296using the various options:</p>
297</div>
298<h2>OPTIONS</h2>
299<div class="sectionbody">
300<dl>
301<dt>
302--add
303</dt>
304<dd>
305<p>
306 If a specified file isn't in the index already then it's
307 added.
308 Default behaviour is to ignore new files.
309</p>
310</dd>
311<dt>
312--remove
313</dt>
314<dd>
315<p>
316 If a specified file is in the index but is missing then it's
317 removed.
Junio C Hamano341071d2006-06-04 07:24:48318 Default behavior is to ignore removed file.
Junio C Hamano1a4e8412005-12-27 08:17:23319</p>
320</dd>
321<dt>
322--refresh
323</dt>
324<dd>
325<p>
326 Looks at the current index and checks to see if merges or
327 updates are needed by checking stat() information.
328</p>
329</dd>
330<dt>
331-q
332</dt>
333<dd>
334<p>
335 Quiet. If --refresh finds that the index needs an update, the
336 default behavior is to error out. This option makes
337 git-update-index continue anyway.
338</p>
339</dd>
340<dt>
341--unmerged
342</dt>
343<dd>
344<p>
345 If --refresh finds unmerged changes in the index, the default
346 behavior is to error out. This option makes git-update-index
347 continue anyway.
348</p>
349</dd>
350<dt>
351--ignore-missing
352</dt>
353<dd>
354<p>
355 Ignores missing files during a --refresh
356</p>
357</dd>
358<dt>
359--cacheinfo &lt;mode&gt; &lt;object&gt; &lt;path&gt;
360</dt>
361<dd>
362<p>
363 Directly insert the specified info into the index.
364</p>
365</dd>
366<dt>
367--index-info
368</dt>
369<dd>
370<p>
371 Read index information from stdin.
372</p>
373</dd>
374<dt>
375--chmod=(+|-)x
376</dt>
377<dd>
378<p>
379 Set the execute permissions on the updated files.
380</p>
381</dd>
382<dt>
Junio C Hamano7e9f6b72006-02-22 10:44:55383--assume-unchanged, --no-assume-unchanged
384</dt>
385<dd>
386<p>
387 When these flags are specified, the object name recorded
388 for the paths are not updated. Instead, these options
389 sets and unsets the "assume unchanged" bit for the
390 paths. When the "assume unchanged" bit is on, git stops
391 checking the working tree files for possible
392 modifications, so you need to manually unset the bit to
393 tell git when you change the working tree file. This is
394 sometimes helpful when working with a big project on a
395 filesystem that has very slow lstat(2) system call
396 (e.g. cifs).
397</p>
398</dd>
399<dt>
Junio C Hamano8a0a21e2006-08-24 07:37:45400--again, -g
Junio C Hamano26a57372006-05-10 00:13:40401</dt>
402<dd>
403<p>
404 Runs <tt>git-update-index</tt> itself on the paths whose index
405 entries are different from those from the <tt>HEAD</tt> commit.
406</p>
407</dd>
408<dt>
Junio C Hamano46338f52006-05-04 00:46:44409--unresolve
410</dt>
411<dd>
412<p>
413 Restores the <em>unmerged</em> or <em>needs updating</em> state of a
414 file during a merge if it was cleared by accident.
415</p>
416</dd>
417<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23418--info-only
419</dt>
420<dd>
421<p>
422 Do not create objects in the object database for all
423 &lt;file&gt; arguments that follow this flag; just insert
424 their object IDs into the index.
425</p>
426</dd>
427<dt>
428--force-remove
429</dt>
430<dd>
431<p>
432 Remove the file from the index even when the working directory
433 still has such a file. (Implies --remove.)
434</p>
435</dd>
436<dt>
437--replace
438</dt>
439<dd>
440<p>
441 By default, when a file <tt>path</tt> exists in the index,
442 git-update-index refuses an attempt to add <tt>path/file</tt>.
443 Similarly if a file <tt>path/file</tt> exists, a file <tt>path</tt>
444 cannot be added. With --replace flag, existing entries
445 that conflicts with the entry being added are
446 automatically removed with warning messages.
447</p>
448</dd>
449<dt>
450--stdin
451</dt>
452<dd>
453<p>
454 Instead of taking list of paths from the command line,
455 read list of paths from the standard input. Paths are
456 separated by LF (i.e. one path per line) by default.
457</p>
458</dd>
459<dt>
460--verbose
461</dt>
462<dd>
463<p>
464 Report what is being added and removed from index.
465</p>
466</dd>
467<dt>
468-z
469</dt>
470<dd>
471<p>
472 Only meaningful with <tt>--stdin</tt>; paths are separated with
473 NUL character instead of LF.
474</p>
475</dd>
476<dt>
Junio C Hamano1bb569e2006-05-05 23:14:25477--
Junio C Hamano1a4e8412005-12-27 08:17:23478</dt>
479<dd>
480<p>
481 Do not interpret any more arguments as options.
482</p>
483</dd>
484<dt>
485&lt;file&gt;
486</dt>
487<dd>
488<p>
489 Files to act on.
490 Note that files beginning with <em>.</em> are discarded. This includes
491 <tt>./file</tt> and <tt>dir/./file</tt>. If you don't want this, then use
492 cleaner names.
493 The same applies to directories ending <em>/</em> and paths with <em>//</em>
494</p>
495</dd>
496</dl>
497</div>
498<h2>Using --refresh</h2>
499<div class="sectionbody">
500<p><em>--refresh</em> does not calculate a new sha1 file or bring the index
501up-to-date for mode/content changes. But what it <strong>does</strong> do is to
502"re-match" the stat information of a file with the index, so that you
503can refresh the index for a file that hasn't been changed but where
504the stat entry is out of date.</p>
505<p>For example, you'd want to do this after doing a "git-read-tree", to link
506up the stat index details with the proper files.</p>
507</div>
508<h2>Using --cacheinfo or --info-only</h2>
509<div class="sectionbody">
510<p><em>--cacheinfo</em> is used to register a file that is not in the
511current working directory. This is useful for minimum-checkout
512merging.</p>
513<p>To pretend you have a file with mode and sha1 at path, say:</p>
514<div class="listingblock">
515<div class="content">
516<pre><tt>$ git-update-index --cacheinfo mode sha1 path</tt></pre>
517</div></div>
518<p><em>--info-only</em> is used to register files without placing them in the object
519database. This is useful for status-only repositories.</p>
520<p>Both <em>--cacheinfo</em> and <em>--info-only</em> behave similarly: the index is updated
521but the object database isn't. <em>--cacheinfo</em> is useful when the object is
522in the database but the file isn't available locally. <em>--info-only</em> is
523useful when the file is available, but you do not wish to update the
524object database.</p>
525</div>
526<h2>Using --index-info</h2>
527<div class="sectionbody">
528<p><tt>--index-info</tt> is a more powerful mechanism that lets you feed
529multiple entry definitions from the standard input, and designed
530specifically for scripts. It can take inputs of three formats:</p>
531<ol>
532<li>
533<p>
534mode SP sha1 TAB path
535</p>
536<p>The first format is what "git-apply --index-info"
537reports, and used to reconstruct a partial tree
538that is used for phony merge base tree when falling
539back on 3-way merge.</p>
540</li>
541<li>
542<p>
543mode SP type SP sha1 TAB path
544</p>
545<p>The second format is to stuff git-ls-tree output
546into the index file.</p>
547</li>
548<li>
549<p>
550mode SP sha1 SP stage TAB path
551</p>
552<p>This format is to put higher order stages into the
553index file and matches git-ls-files --stage output.</p>
554</li>
555</ol>
556<p>To place a higher stage entry to the index, the path should
557first be removed by feeding a mode=0 entry for the path, and
558then feeding necessary input lines in the third format.</p>
559<p>For example, starting with this index:</p>
560<div class="listingblock">
561<div class="content">
562<pre><tt>$ git ls-files -s
563100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz</tt></pre>
564</div></div>
565<p>you can feed the following input to <tt>--index-info</tt>:</p>
566<div class="listingblock">
567<div class="content">
568<pre><tt>$ git update-index --index-info
5690 0000000000000000000000000000000000000000 frotz
570100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz
571100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz</tt></pre>
572</div></div>
573<p>The first line of the input feeds 0 as the mode to remove the
574path; the SHA1 does not matter as long as it is well formatted.
575Then the second and third line feeds stage 1 and stage 2 entries
576for that path. After the above, we would end up with this:</p>
577<div class="listingblock">
578<div class="content">
579<pre><tt>$ git ls-files -s
580100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz
581100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz</tt></pre>
582</div></div>
583</div>
Junio C Hamanofb2ead32006-11-13 23:40:59584<h2>Using &#8220;assume unchanged&#8221; bit</h2>
Junio C Hamano7e9f6b72006-02-22 10:44:55585<div class="sectionbody">
586<p>Many operations in git depend on your filesystem to have an
587efficient <tt>lstat(2)</tt> implementation, so that <tt>st_mtime</tt>
588information for working tree files can be cheaply checked to see
589if the file contents have changed from the version recorded in
590the index file. Unfortunately, some filesystems have
591inefficient <tt>lstat(2)</tt>. If your filesystem is one of them, you
592can set "assume unchanged" bit to paths you have not changed to
593cause git not to do this check. Note that setting this bit on a
594path does not mean git will check the contents of the file to
595see if it has changed &#8212; it makes git to omit any checking and
596assume it has <strong>not</strong> changed. When you make changes to working
597tree files, you have to explicitly tell git about it by dropping
598"assume unchanged" bit, either before or after you modify them.</p>
599<p>In order to set "assume unchanged" bit, use <tt>--assume-unchanged</tt>
600option. To unset, use <tt>--no-assume-unchanged</tt>.</p>
601<p>The command looks at <tt>core.ignorestat</tt> configuration variable. When
602this is true, paths updated with <tt>git-update-index paths&#8230;</tt> and
603paths updated with other git commands that update both index and
604working tree (e.g. <tt>git-apply --index</tt>, <tt>git-checkout-index -u</tt>,
605and <tt>git-read-tree -u</tt>) are automatically marked as "assume
606unchanged". Note that "assume unchanged" bit is <strong>not</strong> set if
607<tt>git-update-index --refresh</tt> finds the working tree file matches
608the index (use <tt>git-update-index --really-refresh</tt> if you want
609to mark them as "assume unchanged").</p>
610</div>
Junio C Hamano1a4e8412005-12-27 08:17:23611<h2>Examples</h2>
612<div class="sectionbody">
613<p>To update and refresh only the files already checked out:</p>
614<div class="listingblock">
615<div class="content">
616<pre><tt>$ git-checkout-index -n -f -a &amp;&amp; git-update-index --ignore-missing --refresh</tt></pre>
617</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01618<dl>
619<dt>
620On an inefficient filesystem with <tt>core.ignorestat</tt> set
621</dt>
622<dd>
Junio C Hamano7e9f6b72006-02-22 10:44:55623<div class="listingblock">
624<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01625<pre><tt>$ git update-index --really-refresh <b>(1)</b>
626$ git update-index --no-assume-unchanged foo.c <b>(2)</b>
627$ git diff --name-only <b>(3)</b>
Junio C Hamano7e9f6b72006-02-22 10:44:55628$ edit foo.c
Junio C Hamanoc8d88c22006-04-29 07:02:01629$ git diff --name-only <b>(4)</b>
Junio C Hamano7e9f6b72006-02-22 10:44:55630M foo.c
Junio C Hamanoc8d88c22006-04-29 07:02:01631$ git update-index foo.c <b>(5)</b>
632$ git diff --name-only <b>(6)</b>
Junio C Hamano7e9f6b72006-02-22 10:44:55633$ edit foo.c
Junio C Hamanoc8d88c22006-04-29 07:02:01634$ git diff --name-only <b>(7)</b>
635$ git update-index --no-assume-unchanged foo.c <b>(8)</b>
636$ git diff --name-only <b>(9)</b>
637M foo.c</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55638</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01639<ol>
640<li>
641<p>
642forces lstat(2) to set "assume unchanged" bits for paths that match index.
643</p>
644</li>
645<li>
646<p>
647mark the path to be edited.
648</p>
649</li>
650<li>
651<p>
652this does lstat(2) and finds index matches the path.
653</p>
654</li>
655<li>
656<p>
657this does lstat(2) and finds index does <strong>not</strong> match the path.
658</p>
659</li>
660<li>
661<p>
662registering the new version to index sets "assume unchanged" bit.
663</p>
664</li>
665<li>
666<p>
667and it is assumed unchanged.
668</p>
669</li>
670<li>
671<p>
672even after you edit it.
673</p>
674</li>
675<li>
676<p>
677you can tell about the change after the fact.
678</p>
679</li>
680<li>
681<p>
682now it checks with lstat(2) and finds it has been changed.
683</p>
684</li>
685</ol>
686</dd>
687</dl>
Junio C Hamano1a4e8412005-12-27 08:17:23688</div>
689<h2>Configuration</h2>
690<div class="sectionbody">
691<p>The command honors <tt>core.filemode</tt> configuration variable. If
692your repository is on an filesystem whose executable bits are
Junio C Hamano7ad22dc2007-01-29 02:55:48693unreliable, 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:23694This causes the command to ignore differences in file modes recorded
695in the index and the file mode on the filesystem if they differ only on
696executable bit. On such an unfortunate filesystem, you may
697need to use <tt>git-update-index --chmod=</tt>.</p>
Junio C Hamanoaa83a7d2007-03-05 02:37:29698<p>Quite similarly, if <tt>core.symlinks</tt> configuration variable is set
699to <em>false</em> (see <a href="git-config.html">git-config(1)</a>), symbolic links are checked out
700as plain files, and this command does not modify a recorded file mode
701from symbolic link to regular file.</p>
Junio C Hamano7e9f6b72006-02-22 10:44:55702<p>The command looks at <tt>core.ignorestat</tt> configuration variable. See
703<em>Using "assume unchanged" bit</em> section above.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23704</div>
705<h2>See Also</h2>
706<div class="sectionbody">
Junio C Hamano3d30fd52007-05-08 00:32:53707<p><a href="git-config.html">git-config(1)</a>,
708<a href="git-add.html">git-add(1)</a></p>
Junio C Hamano1a4e8412005-12-27 08:17:23709</div>
710<h2>Author</h2>
711<div class="sectionbody">
712<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
713</div>
714<h2>Documentation</h2>
715<div class="sectionbody">
716<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
717</div>
718<h2>GIT</h2>
719<div class="sectionbody">
720<p>Part of the <a href="git.html">git(7)</a> suite</p>
721</div>
722<div id="footer">
723<div id="footer-text">
Junio C Hamano35738e82008-01-07 07:55:46724Last updated 07-Jan-2008 07:50:55 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23725</div>
726</div>
727</body>
728</html>