]>
Commit | Line | Data |
---|---|---|
215a7ad1 | 1 | git-update-index(1) |
2cf565c5 | 2 | =================== |
2cf565c5 DG |
3 | |
4 | NAME | |
5 | ---- | |
c3f0baac | 6 | git-update-index - Register file contents in the working tree to the index |
2cf565c5 DG |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
f9666adf | 11 | [verse] |
b1889c36 | 12 | 'git update-index' |
de5f2bf3 MK |
13 | [--add] [--remove | --force-remove] [--replace] |
14 | [--refresh] [-q] [--unmerged] [--ignore-missing] | |
ec160ae1 | 15 | [(--cacheinfo <mode>,<object>,<file>)...] |
5773c9f2 | 16 | [--chmod=(+|-)x] |
0460ed2c FC |
17 | [--[no-]assume-unchanged] |
18 | [--[no-]skip-worktree] | |
8dfb04ae | 19 | [--[no-]ignore-skip-worktree-entries] |
780494b1 | 20 | [--[no-]fsmonitor-valid] |
5fdeacb0 | 21 | [--ignore-submodules] |
bc497127 | 22 | [--[no-]split-index] |
eaab83d0 | 23 | [--[no-|test-|force-]untracked-cache] |
780494b1 | 24 | [--[no-]fsmonitor] |
7099c9c7 | 25 | [--really-refresh] [--unresolve] [--again | -g] |
14470c0d | 26 | [--info-only] [--index-info] |
69dec66b | 27 | [-z] [--stdin] [--index-version <n>] |
14470c0d | 28 | [--verbose] |
0adda936 | 29 | [--] [<file>...] |
2cf565c5 DG |
30 | |
31 | DESCRIPTION | |
32 | ----------- | |
b356d236 UG |
33 | Modifies the index. Each file mentioned is updated into the index and |
34 | any 'unmerged' or 'needs updating' state is cleared. | |
2cf565c5 | 35 | |
5162e697 | 36 | See also linkgit:git-add[1] for a more user-friendly way to do some of |
e701ccc3 MM |
37 | the most common operations on the index. |
38 | ||
0b444cdb | 39 | The way 'git update-index' handles files it is told about can be modified |
2cf565c5 DG |
40 | using the various options: |
41 | ||
42 | OPTIONS | |
43 | ------- | |
44 | --add:: | |
5f3aa197 | 45 | If a specified file isn't in the index already then it's |
2cf565c5 DG |
46 | added. |
47 | Default behaviour is to ignore new files. | |
48 | ||
49 | --remove:: | |
5f3aa197 | 50 | If a specified file is in the index but is missing then it's |
2cf565c5 | 51 | removed. |
6cc668c0 | 52 | Default behavior is to ignore removed files. |
2cf565c5 DG |
53 | |
54 | --refresh:: | |
5f3aa197 | 55 | Looks at the current index and checks to see if merges or |
2cf565c5 DG |
56 | updates are needed by checking stat() information. |
57 | ||
14470c0d | 58 | -q:: |
5f3aa197 | 59 | Quiet. If --refresh finds that the index needs an update, the |
14470c0d | 60 | default behavior is to error out. This option makes |
0b444cdb | 61 | 'git update-index' continue anyway. |
14470c0d | 62 | |
04c8ce9c | 63 | --ignore-submodules:: |
5fdeacb0 JS |
64 | Do not try to update submodules. This option is only respected |
65 | when passed before --refresh. | |
66 | ||
14470c0d | 67 | --unmerged:: |
5f3aa197 | 68 | If --refresh finds unmerged changes in the index, the default |
0b444cdb | 69 | behavior is to error out. This option makes 'git update-index' |
14470c0d CS |
70 | continue anyway. |
71 | ||
2cf565c5 DG |
72 | --ignore-missing:: |
73 | Ignores missing files during a --refresh | |
74 | ||
ec160ae1 | 75 | --cacheinfo <mode>,<object>,<path>:: |
2cf565c5 | 76 | --cacheinfo <mode> <object> <path>:: |
ec160ae1 JH |
77 | Directly insert the specified info into the index. For |
78 | backward compatibility, you can also give these three | |
79 | arguments as three separate parameters, but new users are | |
80 | encouraged to use a single-parameter form. | |
a6080a0a | 81 | |
14470c0d | 82 | --index-info:: |
7acab8f1 | 83 | Read index information from stdin. |
14470c0d CS |
84 | |
85 | --chmod=(+|-)x:: | |
a6080a0a | 86 | Set the execute permissions on the updated files. |
14470c0d | 87 | |
0460ed2c | 88 | --[no-]assume-unchanged:: |
ccadb25f PO |
89 | When this flag is specified, the object names recorded |
90 | for the paths are not updated. Instead, this option | |
91 | sets/unsets the "assume unchanged" bit for the | |
92 | paths. When the "assume unchanged" bit is on, the user | |
93 | promises not to change the file and allows Git to assume | |
94 | that the working tree file matches what is recorded in | |
95 | the index. If you want to change the working tree file, | |
96 | you need to unset the bit to tell Git. This is | |
f9666adf | 97 | sometimes helpful when working with a big project on a |
0a4f051f | 98 | filesystem that has a very slow lstat(2) system call |
f9666adf | 99 | (e.g. cifs). |
6259ac66 | 100 | + |
6259ac66 PB |
101 | Git will fail (gracefully) in case it needs to modify this file |
102 | in the index e.g. when merging in a commit; | |
103 | thus, in case the assumed-untracked file is changed upstream, | |
104 | you will need to handle the situation manually. | |
f9666adf | 105 | |
466d1f15 | 106 | --really-refresh:: |
bcf9626a | 107 | Like `--refresh`, but checks stat information unconditionally, |
466d1f15 ŠN |
108 | without regard to the "assume unchanged" setting. |
109 | ||
0460ed2c | 110 | --[no-]skip-worktree:: |
6cc668c0 | 111 | When one of these flags is specified, the object names recorded |
44a36913 NTND |
112 | for the paths are not updated. Instead, these options |
113 | set and unset the "skip-worktree" bit for the paths. See | |
114 | section "Skip-worktree bit" below for more information. | |
115 | ||
8dfb04ae JS |
116 | |
117 | --[no-]ignore-skip-worktree-entries:: | |
118 | Do not remove skip-worktree (AKA "index-only") entries even when | |
119 | the `--remove` option was specified. | |
120 | ||
780494b1 | 121 | --[no-]fsmonitor-valid:: |
6cc668c0 | 122 | When one of these flags is specified, the object names recorded |
780494b1 BP |
123 | for the paths are not updated. Instead, these options |
124 | set and unset the "fsmonitor valid" bit for the paths. See | |
125 | section "File System Monitor" below for more information. | |
126 | ||
3240240f SB |
127 | -g:: |
128 | --again:: | |
0b444cdb | 129 | Runs 'git update-index' itself on the paths whose index |
9a9fd289 | 130 | entries are different from those of the `HEAD` commit. |
83e77a25 | 131 | |
060729dd MK |
132 | --unresolve:: |
133 | Restores the 'unmerged' or 'needs updating' state of a | |
134 | file during a merge if it was cleared by accident. | |
135 | ||
df6e1516 BL |
136 | --info-only:: |
137 | Do not create objects in the object database for all | |
138 | <file> arguments that follow this flag; just insert | |
5f3aa197 | 139 | their object IDs into the index. |
df6e1516 | 140 | |
2cf565c5 DG |
141 | --force-remove:: |
142 | Remove the file from the index even when the working directory | |
9b63f501 | 143 | still has such a file. (Implies --remove.) |
2cf565c5 DG |
144 | |
145 | --replace:: | |
146 | By default, when a file `path` exists in the index, | |
0b444cdb | 147 | 'git update-index' refuses an attempt to add `path/file`. |
2cf565c5 DG |
148 | Similarly if a file `path/file` exists, a file `path` |
149 | cannot be added. With --replace flag, existing entries | |
04c8ce9c | 150 | that conflict with the entry being added are |
2cf565c5 DG |
151 | automatically removed with warning messages. |
152 | ||
1f7f99de | 153 | --stdin:: |
0a4f051f EN |
154 | Instead of taking a list of paths from the command line, |
155 | read a list of paths from the standard input. Paths are | |
1f7f99de JH |
156 | separated by LF (i.e. one path per line) by default. |
157 | ||
14470c0d | 158 | --verbose:: |
0a4f051f | 159 | Report what is being added and removed from the index. |
14470c0d | 160 | |
69dec66b JH |
161 | --index-version <n>:: |
162 | Write the resulting index out in the named on-disk format version. | |
4d542687 | 163 | Supported versions are 2, 3, and 4. The current default version is 2 |
647d8794 | 164 | or 3, depending on whether extra features are used, such as |
606e088d JH |
165 | `git add -N`. With `--verbose`, also report the version the index |
166 | file uses before and after this command. | |
647d8794 NTND |
167 | + |
168 | Version 4 performs a simple pathname compression that reduces index | |
169 | size by 30%-50% on large repositories, which results in faster load | |
764b2330 JH |
170 | time. Git supports it since version 1.8.0, released in October 2012, |
171 | and support for it was added to libgit2 in 2016 and to JGit in 2020. | |
172 | Older versions of this manual page called it "relatively young", but | |
173 | it should be considered mature technology these days. | |
174 | ||
606e088d JH |
175 | --show-index-version:: |
176 | Report the index format version used by the on-disk index file. | |
177 | See `--index-version` above. | |
69dec66b | 178 | |
1f7f99de | 179 | -z:: |
537497be BW |
180 | Only meaningful with `--stdin` or `--index-info`; paths are |
181 | separated with NUL character instead of LF. | |
1f7f99de | 182 | |
c18b80a0 NTND |
183 | --split-index:: |
184 | --no-split-index:: | |
b4601395 CC |
185 | Enable or disable split index mode. If split-index mode is |
186 | already enabled and `--split-index` is given again, all | |
187 | changes in $GIT_DIR/index are pushed back to the shared index | |
188 | file. | |
13c0e4c4 CC |
189 | + |
190 | These options take effect whatever the value of the `core.splitIndex` | |
191 | configuration variable (see linkgit:git-config[1]). But a warning is | |
192 | emitted when the change goes against the configured value, as the | |
193 | configured value will take effect next time the index is read and this | |
194 | will remove the intended effect of the option. | |
c18b80a0 | 195 | |
9e597241 NTND |
196 | --untracked-cache:: |
197 | --no-untracked-cache:: | |
435ec090 CC |
198 | Enable or disable untracked cache feature. Please use |
199 | `--test-untracked-cache` before enabling it. | |
200 | + | |
201 | These options take effect whatever the value of the `core.untrackedCache` | |
202 | configuration variable (see linkgit:git-config[1]). But a warning is | |
203 | emitted when the change goes against the configured value, as the | |
204 | configured value will take effect next time the index is read and this | |
205 | will remove the intended effect of the option. | |
9e597241 | 206 | |
eaab83d0 CC |
207 | --test-untracked-cache:: |
208 | Only perform tests on the working directory to make sure | |
209 | untracked cache can be used. You have to manually enable | |
435ec090 CC |
210 | untracked cache using `--untracked-cache` or |
211 | `--force-untracked-cache` or the `core.untrackedCache` | |
212 | configuration variable afterwards if you really want to use | |
213 | it. If a test fails the exit code is 1 and a message | |
214 | explains what is not working as needed, otherwise the exit | |
215 | code is 0 and OK is printed. | |
eaab83d0 | 216 | |
f64cb88d | 217 | --force-untracked-cache:: |
435ec090 CC |
218 | Same as `--untracked-cache`. Provided for backwards |
219 | compatibility with older versions of Git where | |
220 | `--untracked-cache` used to imply `--test-untracked-cache` but | |
221 | this option would enable the extension unconditionally. | |
f64cb88d | 222 | |
780494b1 BP |
223 | --fsmonitor:: |
224 | --no-fsmonitor:: | |
225 | Enable or disable files system monitor feature. These options | |
226 | take effect whatever the value of the `core.fsmonitor` | |
227 | configuration variable (see linkgit:git-config[1]). But a warning | |
228 | is emitted when the change goes against the configured value, as | |
229 | the configured value will take effect next time the index is | |
230 | read and this will remove the intended effect of the option. | |
231 | ||
e994004f | 232 | \--:: |
2cf565c5 DG |
233 | Do not interpret any more arguments as options. |
234 | ||
235 | <file>:: | |
236 | Files to act on. | |
5773c9f2 | 237 | Note that files beginning with '.' are discarded. This includes |
a6080a0a | 238 | `./file` and `dir/./file`. If you don't want this, then use |
2cf565c5 DG |
239 | cleaner names. |
240 | The same applies to directories ending '/' and paths with '//' | |
241 | ||
76a8788c | 242 | USING --REFRESH |
2cf565c5 | 243 | --------------- |
bcf9626a | 244 | `--refresh` does not calculate a new sha1 file or bring the index |
7560f547 | 245 | up to date for mode/content changes. But what it *does* do is to |
5f3aa197 LS |
246 | "re-match" the stat information of a file with the index, so that you |
247 | can refresh the index for a file that hasn't been changed but where | |
2cf565c5 DG |
248 | the stat entry is out of date. |
249 | ||
0b444cdb | 250 | For example, you'd want to do this after doing a 'git read-tree', to link |
5f3aa197 | 251 | up the stat index details with the proper files. |
2cf565c5 | 252 | |
76a8788c | 253 | USING --CACHEINFO OR --INFO-ONLY |
df6e1516 | 254 | -------------------------------- |
bcf9626a | 255 | `--cacheinfo` is used to register a file that is not in the |
df6e1516 BL |
256 | current working directory. This is useful for minimum-checkout |
257 | merging. | |
258 | ||
388d0ff6 | 259 | To pretend you have a file at path with mode and sha1, say: |
2cf565c5 | 260 | |
61f693bd | 261 | ---------------- |
388d0ff6 | 262 | $ git update-index --add --cacheinfo <mode>,<sha1>,<path> |
61f693bd | 263 | ---------------- |
2cf565c5 | 264 | |
bcf9626a | 265 | `--info-only` is used to register files without placing them in the object |
df6e1516 | 266 | database. This is useful for status-only repositories. |
2cf565c5 | 267 | |
bcf9626a MM |
268 | Both `--cacheinfo` and `--info-only` behave similarly: the index is updated |
269 | but the object database isn't. `--cacheinfo` is useful when the object is | |
270 | in the database but the file isn't available locally. `--info-only` is | |
df6e1516 BL |
271 | useful when the file is available, but you do not wish to update the |
272 | object database. | |
273 | ||
d23748a6 | 274 | |
76a8788c | 275 | USING --INDEX-INFO |
d23748a6 JH |
276 | ------------------ |
277 | ||
278 | `--index-info` is a more powerful mechanism that lets you feed | |
279 | multiple entry definitions from the standard input, and designed | |
280 | specifically for scripts. It can take inputs of three formats: | |
281 | ||
d23748a6 JH |
282 | . mode SP type SP sha1 TAB path |
283 | + | |
e05aa688 | 284 | This format is to stuff `git ls-tree` output into the index. |
d23748a6 JH |
285 | |
286 | . mode SP sha1 SP stage TAB path | |
287 | + | |
288 | This format is to put higher order stages into the | |
0b444cdb | 289 | index file and matches 'git ls-files --stage' output. |
d23748a6 | 290 | |
e05aa688 JH |
291 | . mode SP sha1 TAB path |
292 | + | |
293 | This format is no longer produced by any Git command, but is | |
294 | and will continue to be supported by `update-index --index-info`. | |
295 | ||
d23748a6 JH |
296 | To place a higher stage entry to the index, the path should |
297 | first be removed by feeding a mode=0 entry for the path, and | |
298 | then feeding necessary input lines in the third format. | |
299 | ||
300 | For example, starting with this index: | |
301 | ||
302 | ------------ | |
303 | $ git ls-files -s | |
304 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz | |
305 | ------------ | |
306 | ||
307 | you can feed the following input to `--index-info`: | |
308 | ||
309 | ------------ | |
310 | $ git update-index --index-info | |
311 | 0 0000000000000000000000000000000000000000 frotz | |
312 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz | |
313 | 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz | |
314 | ------------ | |
315 | ||
316 | The first line of the input feeds 0 as the mode to remove the | |
d5fa1f1a | 317 | path; the SHA-1 does not matter as long as it is well formatted. |
d23748a6 JH |
318 | Then the second and third line feeds stage 1 and stage 2 entries |
319 | for that path. After the above, we would end up with this: | |
320 | ||
321 | ------------ | |
322 | $ git ls-files -s | |
323 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz | |
324 | 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz | |
325 | ------------ | |
326 | ||
327 | ||
76a8788c | 328 | USING ``ASSUME UNCHANGED'' BIT |
bae777db | 329 | ------------------------------ |
f9666adf | 330 | |
2de9b711 | 331 | Many operations in Git depend on your filesystem to have an |
f9666adf JH |
332 | efficient `lstat(2)` implementation, so that `st_mtime` |
333 | information for working tree files can be cheaply checked to see | |
334 | if the file contents have changed from the version recorded in | |
335 | the index file. Unfortunately, some filesystems have | |
336 | inefficient `lstat(2)`. If your filesystem is one of them, you | |
337 | can set "assume unchanged" bit to paths you have not changed to | |
2de9b711 TA |
338 | cause Git not to do this check. Note that setting this bit on a |
339 | path does not mean Git will check the contents of the file to | |
340 | see if it has changed -- it makes Git to omit any checking and | |
f9666adf | 341 | assume it has *not* changed. When you make changes to working |
2de9b711 | 342 | tree files, you have to explicitly tell Git about it by dropping |
f9666adf JH |
343 | "assume unchanged" bit, either before or after you modify them. |
344 | ||
345 | In order to set "assume unchanged" bit, use `--assume-unchanged` | |
acd6d7e7 SN |
346 | option. To unset, use `--no-assume-unchanged`. To see which files |
347 | have the "assume unchanged" bit set, use `git ls-files -v` | |
348 | (see linkgit:git-ls-files[1]). | |
f9666adf JH |
349 | |
350 | The command looks at `core.ignorestat` configuration variable. When | |
b1889c36 | 351 | this is true, paths updated with `git update-index paths...` and |
2de9b711 | 352 | paths updated with other Git commands that update both index and |
0b444cdb TR |
353 | working tree (e.g. 'git apply --index', 'git checkout-index -u', |
354 | and 'git read-tree -u') are automatically marked as "assume | |
f9666adf | 355 | unchanged". Note that "assume unchanged" bit is *not* set if |
b1889c36 JN |
356 | `git update-index --refresh` finds the working tree file matches |
357 | the index (use `git update-index --really-refresh` if you want | |
f9666adf JH |
358 | to mark them as "assume unchanged"). |
359 | ||
9023535b EN |
360 | Sometimes users confuse the assume-unchanged bit with the |
361 | skip-worktree bit. See the final paragraph in the "Skip-worktree bit" | |
362 | section below for an explanation of the differences. | |
363 | ||
f9666adf | 364 | |
76a8788c | 365 | EXAMPLES |
df6e1516 | 366 | -------- |
2cf565c5 DG |
367 | To update and refresh only the files already checked out: |
368 | ||
61f693bd | 369 | ---------------- |
b1889c36 | 370 | $ git checkout-index -n -f -a && git update-index --ignore-missing --refresh |
61f693bd | 371 | ---------------- |
2cf565c5 | 372 | |
48aeecdc SE |
373 | On an inefficient filesystem with `core.ignorestat` set:: |
374 | + | |
f9666adf | 375 | ------------ |
48aeecdc SE |
376 | $ git update-index --really-refresh <1> |
377 | $ git update-index --no-assume-unchanged foo.c <2> | |
378 | $ git diff --name-only <3> | |
f9666adf | 379 | $ edit foo.c |
48aeecdc | 380 | $ git diff --name-only <4> |
f9666adf | 381 | M foo.c |
48aeecdc SE |
382 | $ git update-index foo.c <5> |
383 | $ git diff --name-only <6> | |
f9666adf | 384 | $ edit foo.c |
48aeecdc SE |
385 | $ git diff --name-only <7> |
386 | $ git update-index --no-assume-unchanged foo.c <8> | |
387 | $ git diff --name-only <9> | |
f9666adf | 388 | M foo.c |
48aeecdc SE |
389 | ------------ |
390 | + | |
391 | <1> forces lstat(2) to set "assume unchanged" bits for paths that match index. | |
f9666adf JH |
392 | <2> mark the path to be edited. |
393 | <3> this does lstat(2) and finds index matches the path. | |
48aeecdc | 394 | <4> this does lstat(2) and finds index does *not* match the path. |
f9666adf JH |
395 | <5> registering the new version to index sets "assume unchanged" bit. |
396 | <6> and it is assumed unchanged. | |
397 | <7> even after you edit it. | |
398 | <8> you can tell about the change after the fact. | |
399 | <9> now it checks with lstat(2) and finds it has been changed. | |
f9666adf | 400 | |
2cf565c5 | 401 | |
76a8788c | 402 | SKIP-WORKTREE BIT |
44a36913 NTND |
403 | ----------------- |
404 | ||
9023535b EN |
405 | Skip-worktree bit can be defined in one (long) sentence: Tell git to |
406 | avoid writing the file to the working directory when reasonably | |
407 | possible, and treat the file as unchanged when it is not | |
408 | present in the working directory. | |
409 | ||
410 | Note that not all git commands will pay attention to this bit, and | |
411 | some only partially support it. | |
412 | ||
413 | The update-index flags and the read-tree capabilities relating to the | |
414 | skip-worktree bit predated the introduction of the | |
415 | linkgit:git-sparse-checkout[1] command, which provides a much easier | |
416 | way to configure and handle the skip-worktree bits. If you want to | |
417 | reduce your working tree to only deal with a subset of the files in | |
418 | the repository, we strongly encourage the use of | |
419 | linkgit:git-sparse-checkout[1] in preference to the low-level | |
420 | update-index and read-tree primitives. | |
421 | ||
422 | The primary purpose of the skip-worktree bit is to enable sparse | |
423 | checkouts, i.e. to have working directories with only a subset of | |
424 | paths present. When the skip-worktree bit is set, Git commands (such | |
425 | as `switch`, `pull`, `merge`) will avoid writing these files. | |
426 | However, these commands will sometimes write these files anyway in | |
427 | important cases such as conflicts during a merge or rebase. Git | |
428 | commands will also avoid treating the lack of such files as an | |
c9dba103 | 429 | intentional deletion; for example `git add -u` will not stage a |
9023535b EN |
430 | deletion for these files and `git commit -a` will not make a commit |
431 | deleting them either. | |
44a36913 NTND |
432 | |
433 | Although this bit looks similar to assume-unchanged bit, its goal is | |
9023535b EN |
434 | different. The assume-unchanged bit is for leaving the file in the |
435 | working tree but having Git omit checking it for changes and presuming | |
436 | that the file has not been changed (though if it can determine without | |
437 | stat'ing the file that it has changed, it is free to record the | |
438 | changes). skip-worktree tells Git to ignore the absence of the file, | |
439 | avoid updating it when possible with commands that normally update | |
440 | much of the working directory (e.g. `checkout`, `switch`, `pull`, | |
441 | etc.), and not have its absence be recorded in commits. Note that in | |
442 | sparse checkouts (setup by `git sparse-checkout` or by configuring | |
443 | core.sparseCheckout to true), if a file is marked as skip-worktree in | |
444 | the index but is found in the working tree, Git will clear the | |
445 | skip-worktree bit for that file. | |
44a36913 | 446 | |
76a8788c | 447 | SPLIT INDEX |
b4601395 CC |
448 | ----------- |
449 | ||
450 | This mode is designed for repositories with very large indexes, and | |
451 | aims at reducing the time it takes to repeatedly write these indexes. | |
452 | ||
453 | In this mode, the index is split into two files, $GIT_DIR/index and | |
454 | $GIT_DIR/sharedindex.<SHA-1>. Changes are accumulated in | |
455 | $GIT_DIR/index, the split index, while the shared index file contains | |
456 | all index entries and stays unchanged. | |
457 | ||
458 | All changes in the split index are pushed back to the shared index | |
459 | file when the number of entries in the split index reaches a level | |
460 | specified by the splitIndex.maxPercentChange config variable (see | |
461 | linkgit:git-config[1]). | |
462 | ||
463 | Each time a new shared index file is created, the old shared index | |
464 | files are deleted if their modification time is older than what is | |
465 | specified by the splitIndex.sharedIndexExpire config variable (see | |
466 | linkgit:git-config[1]). | |
467 | ||
468 | To avoid deleting a shared index file that is still used, its | |
031fd4b9 | 469 | modification time is updated to the current time every time a new split |
b4601395 CC |
470 | index based on the shared index file is either created or read from. |
471 | ||
76a8788c | 472 | UNTRACKED CACHE |
435ec090 CC |
473 | --------------- |
474 | ||
475 | This cache is meant to speed up commands that involve determining | |
476 | untracked files such as `git status`. | |
477 | ||
478 | This feature works by recording the mtime of the working tree | |
479 | directories and then omitting reading directories and stat calls | |
480 | against files in those directories whose mtime hasn't changed. For | |
481 | this to work the underlying operating system and file system must | |
482 | change the `st_mtime` field of directories if files in the directory | |
483 | are added, modified or deleted. | |
484 | ||
485 | You can test whether the filesystem supports that with the | |
486 | `--test-untracked-cache` option. The `--untracked-cache` option used | |
487 | to implicitly perform that test in older versions of Git, but that's | |
488 | no longer the case. | |
489 | ||
490 | If you want to enable (or disable) this feature, it is easier to use | |
491 | the `core.untrackedCache` configuration variable (see | |
492 | linkgit:git-config[1]) than using the `--untracked-cache` option to | |
493 | `git update-index` in each repository, especially if you want to do so | |
494 | across all repositories you use, because you can set the configuration | |
495 | variable to `true` (or `false`) in your `$HOME/.gitconfig` just once | |
496 | and have it affect all repositories you touch. | |
497 | ||
498 | When the `core.untrackedCache` configuration variable is changed, the | |
499 | untracked cache is added to or removed from the index the next time a | |
500 | command reads the index; while when `--[no-|force-]untracked-cache` | |
501 | are used, the untracked cache is immediately added to or removed from | |
502 | the index. | |
44a36913 | 503 | |
9b978691 ÆAB |
504 | Before 2.17, the untracked cache had a bug where replacing a directory |
505 | with a symlink to another directory could cause it to incorrectly show | |
506 | files tracked by git as untracked. See the "status: add a failing test | |
507 | showing a core.untrackedCache bug" commit to git.git. A workaround for | |
508 | that is (and this might work for other undiscovered bugs in the | |
509 | future): | |
510 | ||
511 | ---------------- | |
512 | $ git -c core.untrackedCache=false status | |
513 | ---------------- | |
514 | ||
515 | This bug has also been shown to affect non-symlink cases of replacing | |
516 | a directory with a file when it comes to the internal structures of | |
517 | the untracked cache, but no case has been reported where this resulted in | |
518 | wrong "git status" output. | |
519 | ||
7bf0be75 ÆAB |
520 | There are also cases where existing indexes written by git versions |
521 | before 2.17 will reference directories that don't exist anymore, | |
522 | potentially causing many "could not open directory" warnings to be | |
523 | printed on "git status". These are new warnings for existing issues | |
524 | that were previously silently discarded. | |
525 | ||
526 | As with the bug described above the solution is to one-off do a "git | |
527 | status" run with `core.untrackedCache=false` to flush out the leftover | |
528 | bad data. | |
529 | ||
76a8788c | 530 | FILE SYSTEM MONITOR |
780494b1 BP |
531 | ------------------- |
532 | ||
533 | This feature is intended to speed up git operations for repos that have | |
534 | large working directories. | |
535 | ||
32484869 | 536 | It enables git to work together with a file system monitor (see |
f3ea4bed | 537 | linkgit:git-fsmonitor{litdd}daemon[1] |
32484869 | 538 | and the |
780494b1 BP |
539 | "fsmonitor-watchman" section of linkgit:githooks[5]) that can |
540 | inform it as to what files have been modified. This enables git to avoid | |
541 | having to lstat() every file to find modified files. | |
542 | ||
543 | When used in conjunction with the untracked cache, it can further improve | |
544 | performance by avoiding the cost of scanning the entire working directory | |
545 | looking for new files. | |
546 | ||
547 | If you want to enable (or disable) this feature, it is easier to use | |
548 | the `core.fsmonitor` configuration variable (see | |
32484869 JH |
549 | linkgit:git-config[1]) than using the `--fsmonitor` option to `git |
550 | update-index` in each repository, especially if you want to do so | |
780494b1 | 551 | across all repositories you use, because you can set the configuration |
4ccf461f BP |
552 | variable in your `$HOME/.gitconfig` just once and have it affect all |
553 | repositories you touch. | |
780494b1 BP |
554 | |
555 | When the `core.fsmonitor` configuration variable is changed, the | |
556 | file system monitor is added to or removed from the index the next time | |
557 | a command reads the index. When `--[no-]fsmonitor` are used, the file | |
558 | system monitor is immediately added to or removed from the index. | |
559 | ||
76a8788c | 560 | CONFIGURATION |
5773c9f2 JH |
561 | ------------- |
562 | ||
563 | The command honors `core.filemode` configuration variable. If | |
466d1f15 | 564 | your repository is on a filesystem whose executable bits are |
5162e697 | 565 | unreliable, this should be set to 'false' (see linkgit:git-config[1]). |
61f693bd JL |
566 | This causes the command to ignore differences in file modes recorded |
567 | in the index and the file mode on the filesystem if they differ only on | |
5773c9f2 | 568 | executable bit. On such an unfortunate filesystem, you may |
0b444cdb | 569 | need to use 'git update-index --chmod='. |
5773c9f2 | 570 | |
78a8d641 | 571 | Quite similarly, if `core.symlinks` configuration variable is set |
5162e697 | 572 | to 'false' (see linkgit:git-config[1]), symbolic links are checked out |
78a8d641 JS |
573 | as plain files, and this command does not modify a recorded file mode |
574 | from symbolic link to regular file. | |
575 | ||
f9666adf JH |
576 | The command looks at `core.ignorestat` configuration variable. See |
577 | 'Using "assume unchanged" bit' section above. | |
578 | ||
1ce4790b AR |
579 | The command also looks at `core.trustctime` configuration variable. |
580 | It can be useful when the inode change time is regularly modified by | |
581 | something outside Git (file system crawlers and backup systems use | |
582 | ctime for marking files processed) (see linkgit:git-config[1]). | |
583 | ||
435ec090 CC |
584 | The untracked cache extension can be enabled by the |
585 | `core.untrackedCache` configuration variable (see | |
586 | linkgit:git-config[1]). | |
61f693bd | 587 | |
1b13e903 | 588 | NOTES |
589 | ----- | |
590 | ||
591 | Users often try to use the assume-unchanged and skip-worktree bits | |
592 | to tell Git to ignore changes to files that are tracked. This does not | |
593 | work as expected, since Git may still check working tree files against | |
594 | the index when performing certain operations. In general, Git does not | |
595 | provide a way to ignore changes to tracked files, so alternate solutions | |
596 | are recommended. | |
597 | ||
598 | For example, if the file you want to change is some sort of config file, | |
599 | the repository can include a sample config file that can then be copied | |
600 | into the ignored name and modified. The repository can even include a | |
601 | script to treat the sample file as a template, modifying and copying it | |
602 | automatically. | |
603 | ||
56ae8df5 | 604 | SEE ALSO |
61f693bd | 605 | -------- |
5162e697 | 606 | linkgit:git-config[1], |
acd6d7e7 SN |
607 | linkgit:git-add[1], |
608 | linkgit:git-ls-files[1] | |
61f693bd | 609 | |
2cf565c5 DG |
610 | GIT |
611 | --- | |
9e1f0a85 | 612 | Part of the linkgit:git[1] suite |