1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>git-update-index(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-update-index(
1) Manual Page
409 <div class=
"sectionbody">
410 <p>git-update-index -
411 Register file contents in the working tree to the index
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git update-index
</em>
419 [--add] [--remove | --force-remove] [--replace]
420 [--refresh] [-q] [--unmerged] [--ignore-missing]
421 [(--cacheinfo
<mode
> <object
> <file
>)
…]
423 [--assume-unchanged | --no-assume-unchanged]
424 [--skip-worktree | --no-skip-worktree]
425 [--ignore-submodules]
426 [--really-refresh] [--unresolve] [--again | -g]
427 [--info-only] [--index-info]
430 [--] [
<file
>…]
</div>
431 <div class=
"verseblock-attribution">
434 <h2 id=
"_description">DESCRIPTION
</h2>
435 <div class=
"sectionbody">
436 <div class=
"paragraph"><p>Modifies the index or directory cache. Each file mentioned is updated
437 into the index and any
<em>unmerged
</em> or
<em>needs updating
</em> state is
439 <div class=
"paragraph"><p>See also
<a href=
"git-add.html">git-add(
1)
</a> for a more user-friendly way to do some of
440 the most common operations on the index.
</p></div>
441 <div class=
"paragraph"><p>The way
<em>git update-index
</em> handles files it is told about can be modified
442 using the various options:
</p></div>
444 <h2 id=
"_options">OPTIONS
</h2>
445 <div class=
"sectionbody">
446 <div class=
"dlist"><dl>
452 If a specified file isn
’t in the index already then it
’s
454 Default behaviour is to ignore new files.
462 If a specified file is in the index but is missing then it
’s
464 Default behavior is to ignore removed file.
472 Looks at the current index and checks to see if merges or
473 updates are needed by checking stat() information.
481 Quiet. If --refresh finds that the index needs an update, the
482 default behavior is to error out. This option makes
483 <em>git update-index
</em> continue anyway.
491 Do not try to update submodules. This option is only respected
492 when passed before --refresh.
500 If --refresh finds unmerged changes in the index, the default
501 behavior is to error out. This option makes
<em>git update-index
</em>
510 Ignores missing files during a --refresh
514 --cacheinfo
<mode
> <object
> <path
>
518 Directly insert the specified info into the index.
526 Read index information from stdin.
534 Set the execute permissions on the updated files.
541 --no-assume-unchanged
545 When these flags are specified, the object names recorded
546 for the paths are not updated. Instead, these options
547 set and unset the
"assume unchanged" bit for the
548 paths. When the
"assume unchanged" bit is on, git stops
549 checking the working tree files for possible
550 modifications, so you need to manually unset the bit to
551 tell git when you change the working tree file. This is
552 sometimes helpful when working with a big project on a
553 filesystem that has very slow lstat(
2) system call
556 <div class=
"paragraph"><p>This option can be also used as a coarse file-level mechanism
557 to ignore uncommitted changes in tracked files (akin to what
558 <tt>.gitignore
</tt> does for untracked files).
559 Git will fail (gracefully) in case it needs to modify this file
560 in the index e.g. when merging in a commit;
561 thus, in case the assumed-untracked file is changed upstream,
562 you will need to handle the situation manually.
</p></div>
569 Like
<em>--refresh
</em>, but checks stat information unconditionally,
570 without regard to the
"assume unchanged" setting.
581 When one of these flags is specified, the object name recorded
582 for the paths are not updated. Instead, these options
583 set and unset the
"skip-worktree" bit for the paths. See
584 section
"Skip-worktree bit" below for more information.
595 Runs
<em>git update-index
</em> itself on the paths whose index
596 entries are different from those from the
<tt>HEAD
</tt> commit.
604 Restores the
<em>unmerged
</em> or
<em>needs updating
</em> state of a
605 file during a merge if it was cleared by accident.
613 Do not create objects in the object database for all
614 <file
> arguments that follow this flag; just insert
615 their object IDs into the index.
623 Remove the file from the index even when the working directory
624 still has such a file. (Implies --remove.)
632 By default, when a file
<tt>path
</tt> exists in the index,
633 <em>git update-index
</em> refuses an attempt to add
<tt>path/file
</tt>.
634 Similarly if a file
<tt>path/file
</tt> exists, a file
<tt>path
</tt>
635 cannot be added. With --replace flag, existing entries
636 that conflict with the entry being added are
637 automatically removed with warning messages.
645 Instead of taking list of paths from the command line,
646 read list of paths from the standard input. Paths are
647 separated by LF (i.e. one path per line) by default.
655 Report what is being added and removed from index.
663 Only meaningful with
<tt>--stdin
</tt> or
<tt>--index-info
</tt>; paths are
664 separated with NUL character instead of LF.
672 Do not interpret any more arguments as options.
681 Note that files beginning with
<em>.
</em> are discarded. This includes
682 <tt>./file
</tt> and
<tt>dir/./file
</tt>. If you don
’t want this, then use
684 The same applies to directories ending
<em>/
</em> and paths with
<em>//
</em>
689 <h2 id=
"_using_refresh">Using --refresh
</h2>
690 <div class=
"sectionbody">
691 <div class=
"paragraph"><p><em>--refresh
</em> does not calculate a new sha1 file or bring the index
692 up-to-date for mode/content changes. But what it
<strong>does
</strong> do is to
693 "re-match" the stat information of a file with the index, so that you
694 can refresh the index for a file that hasn
’t been changed but where
695 the stat entry is out of date.
</p></div>
696 <div class=
"paragraph"><p>For example, you
’d want to do this after doing a
<em>git read-tree
</em>, to link
697 up the stat index details with the proper files.
</p></div>
699 <h2 id=
"_using_cacheinfo_or_info_only">Using --cacheinfo or --info-only
</h2>
700 <div class=
"sectionbody">
701 <div class=
"paragraph"><p><em>--cacheinfo
</em> is used to register a file that is not in the
702 current working directory. This is useful for minimum-checkout
704 <div class=
"paragraph"><p>To pretend you have a file with mode and sha1 at path, say:
</p></div>
705 <div class=
"listingblock">
706 <div class=
"content">
707 <pre><tt>$ git update-index --cacheinfo mode sha1 path
</tt></pre>
709 <div class=
"paragraph"><p><em>--info-only
</em> is used to register files without placing them in the object
710 database. This is useful for status-only repositories.
</p></div>
711 <div class=
"paragraph"><p>Both
<em>--cacheinfo
</em> and
<em>--info-only
</em> behave similarly: the index is updated
712 but the object database isn
’t.
<em>--cacheinfo
</em> is useful when the object is
713 in the database but the file isn
’t available locally.
<em>--info-only
</em> is
714 useful when the file is available, but you do not wish to update the
715 object database.
</p></div>
717 <h2 id=
"_using_index_info">Using --index-info
</h2>
718 <div class=
"sectionbody">
719 <div class=
"paragraph"><p><tt>--index-info
</tt> is a more powerful mechanism that lets you feed
720 multiple entry definitions from the standard input, and designed
721 specifically for scripts. It can take inputs of three formats:
</p></div>
722 <div class=
"olist arabic"><ol class=
"arabic">
725 mode SP sha1 TAB path
727 <div class=
"paragraph"><p>The first format is what
"git-apply --index-info"
728 reports, and used to reconstruct a partial tree
729 that is used for phony merge base tree when falling
730 back on
3-way merge.
</p></div>
734 mode SP type SP sha1 TAB path
736 <div class=
"paragraph"><p>The second format is to stuff
<em>git ls-tree
</em> output
737 into the index file.
</p></div>
741 mode SP sha1 SP stage TAB path
743 <div class=
"paragraph"><p>This format is to put higher order stages into the
744 index file and matches
<em>git ls-files --stage
</em> output.
</p></div>
747 <div class=
"paragraph"><p>To place a higher stage entry to the index, the path should
748 first be removed by feeding a mode=
0 entry for the path, and
749 then feeding necessary input lines in the third format.
</p></div>
750 <div class=
"paragraph"><p>For example, starting with this index:
</p></div>
751 <div class=
"listingblock">
752 <div class=
"content">
753 <pre><tt>$ git ls-files -s
754 100644 8a1218a1024a212bb3db30becd860315f9f3ac52
0 frotz
</tt></pre>
756 <div class=
"paragraph"><p>you can feed the following input to
<tt>--index-info
</tt>:
</p></div>
757 <div class=
"listingblock">
758 <div class=
"content">
759 <pre><tt>$ git update-index --index-info
760 0 0000000000000000000000000000000000000000 frotz
761 100644 8a1218a1024a212bb3db30becd860315f9f3ac52
1 frotz
762 100755 8a1218a1024a212bb3db30becd860315f9f3ac52
2 frotz
</tt></pre>
764 <div class=
"paragraph"><p>The first line of the input feeds
0 as the mode to remove the
765 path; the SHA1 does not matter as long as it is well formatted.
766 Then the second and third line feeds stage
1 and stage
2 entries
767 for that path. After the above, we would end up with this:
</p></div>
768 <div class=
"listingblock">
769 <div class=
"content">
770 <pre><tt>$ git ls-files -s
771 100644 8a1218a1024a212bb3db30becd860315f9f3ac52
1 frotz
772 100755 8a1218a1024a212bb3db30becd860315f9f3ac52
2 frotz
</tt></pre>
775 <h2 id=
"_using_8220_assume_unchanged_8221_bit">Using
“assume unchanged
” bit
</h2>
776 <div class=
"sectionbody">
777 <div class=
"paragraph"><p>Many operations in git depend on your filesystem to have an
778 efficient
<tt>lstat(
2)
</tt> implementation, so that
<tt>st_mtime
</tt>
779 information for working tree files can be cheaply checked to see
780 if the file contents have changed from the version recorded in
781 the index file. Unfortunately, some filesystems have
782 inefficient
<tt>lstat(
2)
</tt>. If your filesystem is one of them, you
783 can set
"assume unchanged" bit to paths you have not changed to
784 cause git not to do this check. Note that setting this bit on a
785 path does not mean git will check the contents of the file to
786 see if it has changed
 — it makes git to omit any checking and
787 assume it has
<strong>not
</strong> changed. When you make changes to working
788 tree files, you have to explicitly tell git about it by dropping
789 "assume unchanged" bit, either before or after you modify them.
</p></div>
790 <div class=
"paragraph"><p>In order to set
"assume unchanged" bit, use
<tt>--assume-unchanged
</tt>
791 option. To unset, use
<tt>--no-assume-unchanged
</tt>.
</p></div>
792 <div class=
"paragraph"><p>The command looks at
<tt>core.ignorestat
</tt> configuration variable. When
793 this is true, paths updated with
<tt>git update-index paths
…</tt> and
794 paths updated with other git commands that update both index and
795 working tree (e.g.
<em>git apply --index
</em>,
<em>git checkout-index -u
</em>,
796 and
<em>git read-tree -u
</em>) are automatically marked as
"assume
797 unchanged". Note that
"assume unchanged" bit is
<strong>not
</strong> set if
798 <tt>git update-index --refresh
</tt> finds the working tree file matches
799 the index (use
<tt>git update-index --really-refresh
</tt> if you want
800 to mark them as
"assume unchanged").
</p></div>
802 <h2 id=
"_examples">Examples
</h2>
803 <div class=
"sectionbody">
804 <div class=
"paragraph"><p>To update and refresh only the files already checked out:
</p></div>
805 <div class=
"listingblock">
806 <div class=
"content">
807 <pre><tt>$ git checkout-index -n -f -a
&& git update-index --ignore-missing --refresh
</tt></pre>
809 <div class=
"dlist"><dl>
811 On an inefficient filesystem with
<tt>core.ignorestat
</tt> set
814 <div class=
"listingblock">
815 <div class=
"content">
816 <pre><tt>$ git update-index --really-refresh
<b><1></b>
817 $ git update-index --no-assume-unchanged foo.c
<b><2></b>
818 $ git diff --name-only
<b><3></b>
820 $ git diff --name-only
<b><4></b>
822 $ git update-index foo.c
<b><5></b>
823 $ git diff --name-only
<b><6></b>
825 $ git diff --name-only
<b><7></b>
826 $ git update-index --no-assume-unchanged foo.c
<b><8></b>
827 $ git diff --name-only
<b><9></b>
830 <div class=
"colist arabic"><ol>
833 forces lstat(
2) to set
"assume unchanged" bits for paths that match index.
838 mark the path to be edited.
843 this does lstat(
2) and finds index matches the path.
848 this does lstat(
2) and finds index does
<strong>not
</strong> match the path.
853 registering the new version to index sets
"assume unchanged" bit.
858 and it is assumed unchanged.
863 even after you edit it.
868 you can tell about the change after the fact.
873 now it checks with lstat(
2) and finds it has been changed.
880 <h2 id=
"_skip_worktree_bit">Skip-worktree bit
</h2>
881 <div class=
"sectionbody">
882 <div class=
"paragraph"><p>Skip-worktree bit can be defined in one (long) sentence: When reading
883 an entry, if it is marked as skip-worktree, then Git pretends its
884 working directory version is up to date and read the index version
886 <div class=
"paragraph"><p>To elaborate,
"reading" means checking for file existence, reading
887 file attributes or file content. The working directory version may be
888 present or absent. If present, its content may match against the index
889 version or not. Writing is not affected by this bit, content safety
890 is still first priority. Note that Git
<em>can
</em> update working directory
891 file, that is marked skip-worktree, if it is safe to do so (i.e.
892 working directory version matches index version)
</p></div>
893 <div class=
"paragraph"><p>Although this bit looks similar to assume-unchanged bit, its goal is
894 different from assume-unchanged bit
’s. Skip-worktree also takes
895 precedence over assume-unchanged bit when both are set.
</p></div>
897 <h2 id=
"_configuration">Configuration
</h2>
898 <div class=
"sectionbody">
899 <div class=
"paragraph"><p>The command honors
<tt>core.filemode
</tt> configuration variable. If
900 your repository is on a filesystem whose executable bits are
901 unreliable, this should be set to
<em>false
</em> (see
<a href=
"git-config.html">git-config(
1)
</a>).
902 This causes the command to ignore differences in file modes recorded
903 in the index and the file mode on the filesystem if they differ only on
904 executable bit. On such an unfortunate filesystem, you may
905 need to use
<em>git update-index --chmod=
</em>.
</p></div>
906 <div class=
"paragraph"><p>Quite similarly, if
<tt>core.symlinks
</tt> configuration variable is set
907 to
<em>false
</em> (see
<a href=
"git-config.html">git-config(
1)
</a>), symbolic links are checked out
908 as plain files, and this command does not modify a recorded file mode
909 from symbolic link to regular file.
</p></div>
910 <div class=
"paragraph"><p>The command looks at
<tt>core.ignorestat
</tt> configuration variable. See
911 <em>Using
"assume unchanged" bit
</em> section above.
</p></div>
912 <div class=
"paragraph"><p>The command also looks at
<tt>core.trustctime
</tt> configuration variable.
913 It can be useful when the inode change time is regularly modified by
914 something outside Git (file system crawlers and backup systems use
915 ctime for marking files processed) (see
<a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
917 <h2 id=
"_see_also">SEE ALSO
</h2>
918 <div class=
"sectionbody">
919 <div class=
"paragraph"><p><a href=
"git-config.html">git-config(
1)
</a>,
920 <a href=
"git-add.html">git-add(
1)
</a></p></div>
922 <h2 id=
"_git">GIT
</h2>
923 <div class=
"sectionbody">
924 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
927 <div id=
"footer-text">
928 Last updated
2011-
03-
15 23:
30:
14 UTC