6 git-update-index - Modifies the index or directory cache
12 [--add] [--remove] [--unmerged] [--refresh] [--replace]
13 [--cacheinfo <mode> <object> <file>]\*
25 Modifies the index or directory cache. Each file mentioned is updated
26 into the cache and any 'unmerged' or 'needs updating' state is
29 The way "git-update-index" handles files it is told about can be modified
30 using the various options:
35 If a specified file isn't in the cache already then it's
37 Default behaviour is to ignore new files.
40 If a specified file is in the cache but is missing then it's
42 Default behaviour is to ignore removed file.
45 Looks at the current cache and checks to see if merges or
46 updates are needed by checking stat() information.
49 Ignores missing files during a --refresh
51 --cacheinfo <mode> <object> <path>::
52 Directly insert the specified info into the cache.
55 Do not create objects in the object database for all
56 <file> arguments that follow this flag; just insert
57 their object IDs into the cache.
60 Remove the file from the index even when the working directory
61 still has such a file. (Implies --remove.)
64 By default, when a file `path` exists in the index,
65 git-update-index refuses an attempt to add `path/file`.
66 Similarly if a file `path/file` exists, a file `path`
67 cannot be added. With --replace flag, existing entries
68 that conflicts with the entry being added are
69 automatically removed with warning messages.
72 Instead of taking list of paths from the command line,
73 read list of paths from the standard input. Paths are
74 separated by LF (i.e. one path per line) by default.
77 Only meaningful with `--stdin`; paths are separated with
78 NUL character instead of LF.
81 Do not interpret any more arguments as options.
85 Note that files beginning with '.' are discarded. This includes
86 `./file` and `dir/./file`. If you don't want this, then use
88 The same applies to directories ending '/' and paths with '//'
92 '--refresh' does not calculate a new sha1 file or bring the cache
93 up-to-date for mode/content changes. But what it *does* do is to
94 "re-match" the stat information of a file with the cache, so that you
95 can refresh the cache for a file that hasn't been changed but where
96 the stat entry is out of date.
98 For example, you'd want to do this after doing a "git-read-tree", to link
99 up the stat cache details with the proper files.
101 Using --cacheinfo or --info-only
102 --------------------------------
103 '--cacheinfo' is used to register a file that is not in the
104 current working directory. This is useful for minimum-checkout
107 To pretend you have a file with mode and sha1 at path, say:
109 $ git-update-index --cacheinfo mode sha1 path
111 '--info-only' is used to register files without placing them in the object
112 database. This is useful for status-only repositories.
114 Both '--cacheinfo' and '--info-only' behave similarly: the index is updated
115 but the object database isn't. '--cacheinfo' is useful when the object is
116 in the database but the file isn't available locally. '--info-only' is
117 useful when the file is available, but you do not wish to update the
122 To update and refresh only the files already checked out:
124 git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
130 The command honors `core.filemode` configuration variable. If
131 your repository is on an filesystem whose executable bits are
132 unreliable, this should be set to 'false'. This causes the
133 command to ignore differences in file modes recorded in the
134 index and the file mode on the filesystem if they differ only on
135 executable bit. On such an unfortunate filesystem, you may
136 need to use `git-update-index --chmod=`.
140 Written by Linus Torvalds <torvalds@osdl.org>
144 Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
148 Part of the gitlink:git[7] suite