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                        [--really-refresh] [--unresolve] [--again | -g]
17                        [--info-only] [--index-info]
18                        [-z] [--stdin]
19                        [--verbose]
20                        [--] [<file>]*
21

DESCRIPTION

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

OPTIONS

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

USING --REFRESH

123       --refresh does not calculate a new sha1 file or bring the index
124       up-to-date for mode/content changes. But what it does do is to
125       "re-match" the stat information of a file with the index, so that you
126       can refresh the index for a file that hasn´t been changed but where the
127       stat entry is out of date.
128
129       For example, you´d want to do this after doing a "git-read-tree", to
130       link up the stat index details with the proper files.
131

USING --CACHEINFO OR --INFO-ONLY

133       --cacheinfo is used to register a file that is not in the current
134       working directory. This is useful for minimum-checkout merging.
135
136       To pretend you have a file with mode and sha1 at path, say:
137
138
139
140           $ git-update-index --cacheinfo mode sha1 path
141
142       --info-only is used to register files without placing them in the
143       object database. This is useful for status-only repositories.
144
145       Both --cacheinfo and --info-only behave similarly: the index is updated
146       but the object database isn´t. --cacheinfo is useful when the object is
147       in the database but the file isn´t available locally. --info-only is
148       useful when the file is available, but you do not wish to update the
149       object database.
150

USING --INDEX-INFO

152       --index-info is a more powerful mechanism that lets you feed multiple
153       entry definitions from the standard input, and designed specifically
154       for scripts. It can take inputs of three formats:
155
156
157        1.  mode SP sha1 TAB path
158
159           The first format is what "git-apply --index-info" reports, and used
160           to reconstruct a partial tree that is used for phony merge base
161           tree when falling back on 3-way merge.
162
163        2.  mode SP type SP sha1 TAB path
164
165           The second format is to stuff git-ls-tree output into the index
166           file.
167
168        3.  mode SP sha1 SP stage TAB path
169
170           This format is to put higher order stages into the index file and
171           matches git-ls-files --stage output.
172       To place a higher stage entry to the index, the path should first be
173       removed by feeding a mode=0 entry for the path, and then feeding
174       necessary input lines in the third format.
175
176       For example, starting with this index:
177
178
179
180           $ git ls-files -s
181           100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz
182
183       you can feed the following input to --index-info:
184
185
186
187           $ git update-index --index-info
188           0 0000000000000000000000000000000000000000      frotz
189           100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz
190           100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz
191
192       The first line of the input feeds 0 as the mode to remove the path; the
193       SHA1 does not matter as long as it is well formatted. Then the second
194       and third line feeds stage 1 and stage 2 entries for that path. After
195       the above, we would end up with this:
196
197
198
199           $ git ls-files -s
200           100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz
201           100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz
202
203

USING “ASSUME UNCHANGED” BIT

205       Many operations in git depend on your filesystem to have an efficient
206       lstat(2) implementation, so that st_mtime information for working tree
207       files can be cheaply checked to see if the file contents have changed
208       from the version recorded in the index file. Unfortunately, some
209       filesystems have inefficient lstat(2). If your filesystem is one of
210       them, you can set "assume unchanged" bit to paths you have not changed
211       to cause git not to do this check. Note that setting this bit on a path
212       does not mean git will check the contents of the file to see if it has
213       changed — it makes git to omit any checking and assume it has not
214       changed. When you make changes to working tree files, you have to
215       explicitly tell git about it by dropping "assume unchanged" bit, either
216       before or after you modify them.
217
218       In order to set "assume unchanged" bit, use --assume-unchanged option.
219       To unset, use --no-assume-unchanged.
220
221       The command looks at core.ignorestat configuration variable. When this
222       is true, paths updated with git-update-index paths... and paths updated
223       with other git commands that update both index and working tree (e.g.
224       git-apply --index, git-checkout-index -u, and git-read-tree -u) are
225       automatically marked as "assume unchanged". Note that "assume
226       unchanged" bit is not set if git-update-index --refresh finds the
227       working tree file matches the index (use git-update-index
228       --really-refresh if you want to mark them as "assume unchanged").
229

EXAMPLES

231       To update and refresh only the files already checked out:
232
233
234
235           $ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
236
237
238       On an inefficient filesystem with core.ignorestat set
239
240
241               $ git update-index --really-refresh              (1)
242               $ git update-index --no-assume-unchanged foo.c   (2)
243               $ git diff --name-only                           (3)
244               $ edit foo.c
245               $ git diff --name-only                           (4)
246               M foo.c
247               $ git update-index foo.c                         (5)
248               $ git diff --name-only                           (6)
249               $ edit foo.c
250               $ git diff --name-only                           (7)
251               $ git update-index --no-assume-unchanged foo.c   (8)
252               $ git diff --name-only                           (9)
253               M foo.c
254
255
256           1. forces lstat(2) to set "assume unchanged" bits for paths that
257           match index.
258           2. mark the path to be edited.
259           3. this does lstat(2) and finds index matches the path.
260           4. this does lstat(2) and finds index does not match the path.
261           5. registering the new version to index sets "assume unchanged"
262           bit.
263           6. and it is assumed unchanged.
264           7. even after you edit it.
265           8. you can tell about the change after the fact.
266           9. now it checks with lstat(2) and finds it has been changed.
267

CONFIGURATION

269       The command honors core.filemode configuration variable. If your
270       repository is on an filesystem whose executable bits are unreliable,
271       this should be set to false (see git-config(1)). This causes the
272       command to ignore differences in file modes recorded in the index and
273       the file mode on the filesystem if they differ only on executable bit.
274       On such an unfortunate filesystem, you may need to use git-update-index
275       --chmod=.
276
277       Quite similarly, if core.symlinks configuration variable is set to
278       false (see git-config(1)), symbolic links are checked out as plain
279       files, and this command does not modify a recorded file mode from
280       symbolic link to regular file.
281
282       The command looks at core.ignorestat configuration variable. See Using
283       "assume unchanged" bit section above.
284

SEE ALSO

286       git-config(1), git-add(1)
287

AUTHOR

289       Written by Linus Torvalds <torvalds@osdl.org>
290

DOCUMENTATION

292       Documentation by David Greaves, Junio C Hamano and the git-list
293       <git@vger.kernel.org>.
294

GIT

296       Part of the git(7) suite
297
298
299
300
301Git 1.5.3.3                       10/09/2007               GIT-UPDATE-INDEX(1)
Impressum