1GIT-UPDATE-INDEX(1)               Git Manual               GIT-UPDATE-INDEX(1)
2
3
4

NAME

6       git-update-index - Register file contents in the working tree to the
7       index
8

SYNOPSIS

10       git update-index
11                    [--add] [--remove | --force-remove] [--replace]
12                    [--refresh] [-q] [--unmerged] [--ignore-missing]
13                    [(--cacheinfo <mode> <object> <file>)...]
14                    [--chmod=(+|-)x]
15                    [--assume-unchanged | --no-assume-unchanged]
16                    [--skip-worktree | --no-skip-worktree]
17                    [--ignore-submodules]
18                    [--really-refresh] [--unresolve] [--again | -g]
19                    [--info-only] [--index-info]
20                    [-z] [--stdin]
21                    [--verbose]
22                    [--] [<file>...]
23
24

DESCRIPTION

26       Modifies the index or directory cache. Each file mentioned is updated
27       into the index and any unmerged or needs updating state is cleared.
28
29       See also git-add(1) for a more user-friendly way to do some of the most
30       common operations on the index.
31
32       The way git update-index handles files it is told about can be modified
33       using the various options:
34

OPTIONS

36       --add
37           If a specified file isn’t in the index already then it’s added.
38           Default behaviour is to ignore new files.
39
40       --remove
41           If a specified file is in the index but is missing then it’s
42           removed. Default behavior is to ignore removed file.
43
44       --refresh
45           Looks at the current index and checks to see if merges or updates
46           are needed by checking stat() information.
47
48       -q
49           Quiet. If --refresh finds that the index needs an update, the
50           default behavior is to error out. This option makes git
51           update-index continue anyway.
52
53       --ignore-submodules
54           Do not try to update submodules. This option is only respected when
55           passed before --refresh.
56
57       --unmerged
58           If --refresh finds unmerged changes in the index, the default
59           behavior is to error out. This option makes git update-index
60           continue anyway.
61
62       --ignore-missing
63           Ignores missing files during a --refresh
64
65       --cacheinfo <mode> <object> <path>
66           Directly insert the specified info into the index.
67
68       --index-info
69           Read index information from stdin.
70
71       --chmod=(+|-)x
72           Set the execute permissions on the updated files.
73
74       --assume-unchanged, --no-assume-unchanged
75           When these flags are specified, the object names recorded for the
76           paths are not updated. Instead, these options set and unset the
77           "assume unchanged" bit for the paths. When the "assume unchanged"
78           bit is on, git stops checking the working tree files for possible
79           modifications, so you need to manually unset the bit to tell git
80           when you change the working tree file. This is sometimes helpful
81           when working with a big project on a filesystem that has very slow
82           lstat(2) system call (e.g. cifs).
83
84           This option can be also used as a coarse file-level mechanism to
85           ignore uncommitted changes in tracked files (akin to what
86           .gitignore does for untracked files). Git will fail (gracefully) in
87           case it needs to modify this file in the index e.g. when merging in
88           a commit; thus, in case the assumed-untracked file is changed
89           upstream, you will need to handle the situation manually.
90
91       --really-refresh
92           Like --refresh, but checks stat information unconditionally,
93           without regard to the "assume unchanged" setting.
94
95       --skip-worktree, --no-skip-worktree
96           When one of these flags is specified, the object name recorded for
97           the paths are not updated. Instead, these options set and unset the
98           "skip-worktree" bit for the paths. See section "Skip-worktree bit"
99           below for more information.
100
101       -g, --again
102           Runs git update-index itself on the paths whose index entries are
103           different from those from the HEAD commit.
104
105       --unresolve
106           Restores the unmerged or needs updating state of a file during a
107           merge if it was cleared by accident.
108
109       --info-only
110           Do not create objects in the object database for all <file>
111           arguments that follow this flag; just insert their object IDs into
112           the index.
113
114       --force-remove
115           Remove the file from the index even when the working directory
116           still has such a file. (Implies --remove.)
117
118       --replace
119           By default, when a file path exists in the index, git update-index
120           refuses an attempt to add path/file. Similarly if a file path/file
121           exists, a file path cannot be added. With --replace flag, existing
122           entries that conflict with the entry being added are automatically
123           removed with warning messages.
124
125       --stdin
126           Instead of taking list of paths from the command line, read list of
127           paths from the standard input. Paths are separated by LF (i.e. one
128           path per line) by default.
129
130       --verbose
131           Report what is being added and removed from index.
132
133       -z
134           Only meaningful with --stdin or --index-info; paths are separated
135           with NUL character instead of LF.
136
137       --
138           Do not interpret any more arguments as options.
139
140       <file>
141           Files to act on. Note that files beginning with .  are discarded.
142           This includes ./file and dir/./file. If you don’t want this, then
143           use cleaner names. The same applies to directories ending / and
144           paths with //
145

USING --REFRESH

147       --refresh does not calculate a new sha1 file or bring the index
148       up-to-date for mode/content changes. But what it does do is to
149       "re-match" the stat information of a file with the index, so that you
150       can refresh the index for a file that hasn’t been changed but where the
151       stat entry is out of date.
152
153       For example, you’d want to do this after doing a git read-tree, to link
154       up the stat index details with the proper files.
155

USING --CACHEINFO OR --INFO-ONLY

157       --cacheinfo is used to register a file that is not in the current
158       working directory. This is useful for minimum-checkout merging.
159
160       To pretend you have a file with mode and sha1 at path, say:
161
162           $ git update-index --cacheinfo mode sha1 path
163
164
165       --info-only is used to register files without placing them in the
166       object database. This is useful for status-only repositories.
167
168       Both --cacheinfo and --info-only behave similarly: the index is updated
169       but the object database isn’t. --cacheinfo is useful when the object is
170       in the database but the file isn’t available locally. --info-only is
171       useful when the file is available, but you do not wish to update the
172       object database.
173

USING --INDEX-INFO

175       --index-info is a more powerful mechanism that lets you feed multiple
176       entry definitions from the standard input, and designed specifically
177       for scripts. It can take inputs of three formats:
178
179        1. mode SP sha1 TAB path
180
181           The first format is what "git-apply --index-info" reports, and used
182           to reconstruct a partial tree that is used for phony merge base
183           tree when falling back on 3-way merge.
184
185        2. mode SP type SP sha1 TAB path
186
187           The second format is to stuff git ls-tree output into the index
188           file.
189
190        3. mode SP sha1 SP stage TAB path
191
192           This format is to put higher order stages into the index file and
193           matches git ls-files --stage output.
194
195       To place a higher stage entry to the index, the path should first be
196       removed by feeding a mode=0 entry for the path, and then feeding
197       necessary input lines in the third format.
198
199       For example, starting with this index:
200
201           $ git ls-files -s
202           100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz
203
204
205       you can feed the following input to --index-info:
206
207           $ git update-index --index-info
208           0 0000000000000000000000000000000000000000      frotz
209           100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz
210           100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz
211
212
213       The first line of the input feeds 0 as the mode to remove the path; the
214       SHA1 does not matter as long as it is well formatted. Then the second
215       and third line feeds stage 1 and stage 2 entries for that path. After
216       the above, we would end up with this:
217
218           $ git ls-files -s
219           100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz
220           100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz
221
222

USING “ASSUME UNCHANGED” BIT

224       Many operations in git depend on your filesystem to have an efficient
225       lstat(2) implementation, so that st_mtime information for working tree
226       files can be cheaply checked to see if the file contents have changed
227       from the version recorded in the index file. Unfortunately, some
228       filesystems have inefficient lstat(2). If your filesystem is one of
229       them, you can set "assume unchanged" bit to paths you have not changed
230       to cause git not to do this check. Note that setting this bit on a path
231       does not mean git will check the contents of the file to see if it has
232       changed — it makes git to omit any checking and assume it has not
233       changed. When you make changes to working tree files, you have to
234       explicitly tell git about it by dropping "assume unchanged" bit, either
235       before or after you modify them.
236
237       In order to set "assume unchanged" bit, use --assume-unchanged option.
238       To unset, use --no-assume-unchanged.
239
240       The command looks at core.ignorestat configuration variable. When this
241       is true, paths updated with git update-index paths... and paths updated
242       with other git commands that update both index and working tree (e.g.
243       git apply --index, git checkout-index -u, and git read-tree -u) are
244       automatically marked as "assume unchanged". Note that "assume
245       unchanged" bit is not set if git update-index --refresh finds the
246       working tree file matches the index (use git update-index
247       --really-refresh if you want to mark them as "assume unchanged").
248

EXAMPLES

250       To update and refresh only the files already checked out:
251
252           $ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
253
254
255       On an inefficient filesystem with core.ignorestat set
256
257               $ git update-index --really-refresh              (1)
258               $ git update-index --no-assume-unchanged foo.c   (2)
259               $ git diff --name-only                           (3)
260               $ edit foo.c
261               $ git diff --name-only                           (4)
262               M foo.c
263               $ git update-index foo.c                         (5)
264               $ git diff --name-only                           (6)
265               $ edit foo.c
266               $ git diff --name-only                           (7)
267               $ git update-index --no-assume-unchanged foo.c   (8)
268               $ git diff --name-only                           (9)
269               M foo.c
270
271           1. forces lstat(2) to set "assume unchanged" bits for paths that
272           match index.
273           2. mark the path to be edited.
274           3. this does lstat(2) and finds index matches the path.
275           4. this does lstat(2) and finds index does not match the path.
276           5. registering the new version to index sets "assume unchanged"
277           bit.
278           6. and it is assumed unchanged.
279           7. even after you edit it.
280           8. you can tell about the change after the fact.
281           9. now it checks with lstat(2) and finds it has been changed.
282

SKIP-WORKTREE BIT

284       Skip-worktree bit can be defined in one (long) sentence: When reading
285       an entry, if it is marked as skip-worktree, then Git pretends its
286       working directory version is up to date and read the index version
287       instead.
288
289       To elaborate, "reading" means checking for file existence, reading file
290       attributes or file content. The working directory version may be
291       present or absent. If present, its content may match against the index
292       version or not. Writing is not affected by this bit, content safety is
293       still first priority. Note that Git can update working directory file,
294       that is marked skip-worktree, if it is safe to do so (i.e. working
295       directory version matches index version)
296
297       Although this bit looks similar to assume-unchanged bit, its goal is
298       different from assume-unchanged bit’s. Skip-worktree also takes
299       precedence over assume-unchanged bit when both are set.
300

CONFIGURATION

302       The command honors core.filemode configuration variable. If your
303       repository is on a filesystem whose executable bits are unreliable,
304       this should be set to false (see git-config(1)). This causes the
305       command to ignore differences in file modes recorded in the index and
306       the file mode on the filesystem if they differ only on executable bit.
307       On such an unfortunate filesystem, you may need to use git update-index
308       --chmod=.
309
310       Quite similarly, if core.symlinks configuration variable is set to
311       false (see git-config(1)), symbolic links are checked out as plain
312       files, and this command does not modify a recorded file mode from
313       symbolic link to regular file.
314
315       The command looks at core.ignorestat configuration variable. See Using
316       "assume unchanged" bit section above.
317
318       The command also looks at core.trustctime configuration variable. It
319       can be useful when the inode change time is regularly modified by
320       something outside Git (file system crawlers and backup systems use
321       ctime for marking files processed) (see git-config(1)).
322

SEE ALSO

324       git-config(1), git-add(1)
325

AUTHOR

327       Written by Linus Torvalds <torvalds@osdl.org[1]>
328

DOCUMENTATION

330       Documentation by David Greaves, Junio C Hamano and the git-list
331       <git@vger.kernel.org[2]>.
332

GIT

334       Part of the git(1) suite
335

NOTES

337        1. torvalds@osdl.org
338           mailto:torvalds@osdl.org
339
340        2. git@vger.kernel.org
341           mailto:git@vger.kernel.org
342
343
344
345Git 1.7.4.4                       04/11/2011               GIT-UPDATE-INDEX(1)
Impressum