Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 1 | git-update-index(1) |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 2 | =================== |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | c3f0baa | 2007-01-18 15:53:37 -0800 | [diff] [blame] | 6 | git-update-index - Register file contents in the working tree to the index |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 11 | [verse] |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 12 | 'git update-index' |
Matthias Kestenholz | de5f2bf | 2006-05-03 12:51:40 +0200 | [diff] [blame] | 13 | [--add] [--remove | --force-remove] [--replace] |
| 14 | [--refresh] [-q] [--unmerged] [--ignore-missing] |
Junio C Hamano | ec160ae | 2014-03-23 16:57:28 -0700 | [diff] [blame] | 15 | [(--cacheinfo <mode>,<object>,<file>)...] |
Junio C Hamano | 5773c9f | 2005-10-29 14:32:56 -0700 | [diff] [blame] | 16 | [--chmod=(+|-)x] |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 17 | [--[no-]assume-unchanged] |
| 18 | [--[no-]skip-worktree] |
Ben Peart | 780494b | 2017-09-22 12:35:41 -0400 | [diff] [blame] | 19 | [--[no-]fsmonitor-valid] |
Johannes Schindelin | 5fdeacb | 2008-05-14 18:03:45 +0100 | [diff] [blame] | 20 | [--ignore-submodules] |
Christian Couder | bc49712 | 2015-11-25 10:30:02 +0100 | [diff] [blame] | 21 | [--[no-]split-index] |
Christian Couder | eaab83d | 2016-01-24 16:28:16 +0100 | [diff] [blame] | 22 | [--[no-|test-|force-]untracked-cache] |
Ben Peart | 780494b | 2017-09-22 12:35:41 -0400 | [diff] [blame] | 23 | [--[no-]fsmonitor] |
Junio C Hamano | 7099c9c | 2006-08-23 21:24:47 -0700 | [diff] [blame] | 24 | [--really-refresh] [--unresolve] [--again | -g] |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 25 | [--info-only] [--index-info] |
Junio C Hamano | 69dec66 | 2012-04-04 09:37:02 -0700 | [diff] [blame] | 26 | [-z] [--stdin] [--index-version <n>] |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 27 | [--verbose] |
Štěpán Němec | 0adda93 | 2010-10-08 19:31:17 +0200 | [diff] [blame] | 28 | [--] [<file>...] |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 29 | |
| 30 | DESCRIPTION |
| 31 | ----------- |
| 32 | Modifies the index or directory cache. Each file mentioned is updated |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 33 | into the index and any 'unmerged' or 'needs updating' state is |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 34 | cleared. |
| 35 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 36 | See also linkgit:git-add[1] for a more user-friendly way to do some of |
Matthieu Moy | e701ccc | 2007-05-06 23:11:56 +0200 | [diff] [blame] | 37 | the most common operations on the index. |
| 38 | |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 39 | The way 'git update-index' handles files it is told about can be modified |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 40 | using the various options: |
| 41 | |
| 42 | OPTIONS |
| 43 | ------- |
| 44 | --add:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 45 | If a specified file isn't in the index already then it's |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 46 | added. |
| 47 | Default behaviour is to ignore new files. |
| 48 | |
| 49 | --remove:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 50 | If a specified file is in the index but is missing then it's |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 51 | removed. |
Horst H. von Brand | abda1ef | 2006-06-03 16:27:26 -0400 | [diff] [blame] | 52 | Default behavior is to ignore removed file. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 53 | |
| 54 | --refresh:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 55 | Looks at the current index and checks to see if merges or |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 56 | updates are needed by checking stat() information. |
| 57 | |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 58 | -q:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 59 | Quiet. If --refresh finds that the index needs an update, the |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 60 | default behavior is to error out. This option makes |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 61 | 'git update-index' continue anyway. |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 62 | |
Markus Heidelberg | 04c8ce9 | 2008-12-19 13:14:18 +0100 | [diff] [blame] | 63 | --ignore-submodules:: |
Johannes Schindelin | 5fdeacb | 2008-05-14 18:03:45 +0100 | [diff] [blame] | 64 | Do not try to update submodules. This option is only respected |
| 65 | when passed before --refresh. |
| 66 | |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 67 | --unmerged:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 68 | If --refresh finds unmerged changes in the index, the default |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 69 | behavior is to error out. This option makes 'git update-index' |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 70 | continue anyway. |
| 71 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 72 | --ignore-missing:: |
| 73 | Ignores missing files during a --refresh |
| 74 | |
Junio C Hamano | ec160ae | 2014-03-23 16:57:28 -0700 | [diff] [blame] | 75 | --cacheinfo <mode>,<object>,<path>:: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 76 | --cacheinfo <mode> <object> <path>:: |
Junio C Hamano | ec160ae | 2014-03-23 16:57:28 -0700 | [diff] [blame] | 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. |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 81 | |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 82 | --index-info:: |
Nikolai Weibull | 7acab8f | 2005-11-15 00:20:01 +0100 | [diff] [blame] | 83 | Read index information from stdin. |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 84 | |
| 85 | --chmod=(+|-)x:: |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 86 | Set the execute permissions on the updated files. |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 87 | |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 88 | --[no-]assume-unchanged:: |
Philip Oakley | ccadb25 | 2014-12-06 15:04:30 +0000 | [diff] [blame] | 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 |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 97 | sometimes helpful when working with a big project on a |
| 98 | filesystem that has very slow lstat(2) system call |
| 99 | (e.g. cifs). |
Petr Baudis | 6259ac6 | 2008-07-18 16:11:07 +0200 | [diff] [blame] | 100 | + |
Petr Baudis | 6259ac6 | 2008-07-18 16:11:07 +0200 | [diff] [blame] | 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. |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 105 | |
Štěpán Němec | 466d1f1 | 2009-11-10 19:11:51 +0100 | [diff] [blame] | 106 | --really-refresh:: |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 107 | Like `--refresh`, but checks stat information unconditionally, |
Štěpán Němec | 466d1f1 | 2009-11-10 19:11:51 +0100 | [diff] [blame] | 108 | without regard to the "assume unchanged" setting. |
| 109 | |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 110 | --[no-]skip-worktree:: |
Nguyễn Thái Ngọc Duy | 44a3691 | 2009-08-20 20:46:57 +0700 | [diff] [blame] | 111 | When one of these flags is specified, the object name recorded |
| 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 | |
Ben Peart | 780494b | 2017-09-22 12:35:41 -0400 | [diff] [blame] | 116 | --[no-]fsmonitor-valid:: |
| 117 | When one of these flags is specified, the object name recorded |
| 118 | for the paths are not updated. Instead, these options |
| 119 | set and unset the "fsmonitor valid" bit for the paths. See |
| 120 | section "File System Monitor" below for more information. |
| 121 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 122 | -g:: |
| 123 | --again:: |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 124 | Runs 'git update-index' itself on the paths whose index |
Junio C Hamano | 83e77a2 | 2006-05-05 17:40:47 -0700 | [diff] [blame] | 125 | entries are different from those from the `HEAD` commit. |
| 126 | |
Matthias Kestenholz | 060729d | 2006-05-03 12:53:19 +0200 | [diff] [blame] | 127 | --unresolve:: |
| 128 | Restores the 'unmerged' or 'needs updating' state of a |
| 129 | file during a merge if it was cleared by accident. |
| 130 | |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 131 | --info-only:: |
| 132 | Do not create objects in the object database for all |
| 133 | <file> arguments that follow this flag; just insert |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 134 | their object IDs into the index. |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 135 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 136 | --force-remove:: |
| 137 | Remove the file from the index even when the working directory |
Petr Baudis | 9b63f50 | 2005-05-31 18:52:43 +0200 | [diff] [blame] | 138 | still has such a file. (Implies --remove.) |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 139 | |
| 140 | --replace:: |
| 141 | By default, when a file `path` exists in the index, |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 142 | 'git update-index' refuses an attempt to add `path/file`. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 143 | Similarly if a file `path/file` exists, a file `path` |
| 144 | cannot be added. With --replace flag, existing entries |
Markus Heidelberg | 04c8ce9 | 2008-12-19 13:14:18 +0100 | [diff] [blame] | 145 | that conflict with the entry being added are |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 146 | automatically removed with warning messages. |
| 147 | |
Junio C Hamano | 1f7f99d | 2005-09-26 18:13:32 -0700 | [diff] [blame] | 148 | --stdin:: |
| 149 | Instead of taking list of paths from the command line, |
| 150 | read list of paths from the standard input. Paths are |
| 151 | separated by LF (i.e. one path per line) by default. |
| 152 | |
Chris Shoemaker | 14470c0 | 2005-10-29 17:46:41 -0400 | [diff] [blame] | 153 | --verbose:: |
| 154 | Report what is being added and removed from index. |
| 155 | |
Junio C Hamano | 69dec66 | 2012-04-04 09:37:02 -0700 | [diff] [blame] | 156 | --index-version <n>:: |
| 157 | Write the resulting index out in the named on-disk format version. |
Nguyễn Thái Ngọc Duy | 647d879 | 2013-02-23 09:29:31 +0700 | [diff] [blame] | 158 | Supported versions are 2, 3 and 4. The current default version is 2 |
| 159 | or 3, depending on whether extra features are used, such as |
| 160 | `git add -N`. |
| 161 | + |
| 162 | Version 4 performs a simple pathname compression that reduces index |
| 163 | size by 30%-50% on large repositories, which results in faster load |
Evan Zacks | be94568 | 2017-09-12 15:58:39 -0700 | [diff] [blame] | 164 | time. Version 4 is relatively young (first released in 1.8.0 in |
Nguyễn Thái Ngọc Duy | 647d879 | 2013-02-23 09:29:31 +0700 | [diff] [blame] | 165 | October 2012). Other Git implementations such as JGit and libgit2 |
| 166 | may not support it yet. |
Junio C Hamano | 69dec66 | 2012-04-04 09:37:02 -0700 | [diff] [blame] | 167 | |
Junio C Hamano | 1f7f99d | 2005-09-26 18:13:32 -0700 | [diff] [blame] | 168 | -z:: |
Bert Wesarg | 537497b | 2010-10-08 08:50:20 +0200 | [diff] [blame] | 169 | Only meaningful with `--stdin` or `--index-info`; paths are |
| 170 | separated with NUL character instead of LF. |
Junio C Hamano | 1f7f99d | 2005-09-26 18:13:32 -0700 | [diff] [blame] | 171 | |
Nguyễn Thái Ngọc Duy | c18b80a | 2014-06-13 19:19:44 +0700 | [diff] [blame] | 172 | --split-index:: |
| 173 | --no-split-index:: |
Christian Couder | b460139 | 2017-03-06 10:42:03 +0100 | [diff] [blame] | 174 | Enable or disable split index mode. If split-index mode is |
| 175 | already enabled and `--split-index` is given again, all |
| 176 | changes in $GIT_DIR/index are pushed back to the shared index |
| 177 | file. |
Christian Couder | 13c0e4c | 2017-02-27 19:00:06 +0100 | [diff] [blame] | 178 | + |
| 179 | These options take effect whatever the value of the `core.splitIndex` |
| 180 | configuration variable (see linkgit:git-config[1]). But a warning is |
| 181 | emitted when the change goes against the configured value, as the |
| 182 | configured value will take effect next time the index is read and this |
| 183 | will remove the intended effect of the option. |
Nguyễn Thái Ngọc Duy | c18b80a | 2014-06-13 19:19:44 +0700 | [diff] [blame] | 184 | |
Nguyễn Thái Ngọc Duy | 9e59724 | 2015-03-08 17:12:42 +0700 | [diff] [blame] | 185 | --untracked-cache:: |
| 186 | --no-untracked-cache:: |
Christian Couder | 435ec09 | 2016-01-27 07:58:05 +0100 | [diff] [blame] | 187 | Enable or disable untracked cache feature. Please use |
| 188 | `--test-untracked-cache` before enabling it. |
| 189 | + |
| 190 | These options take effect whatever the value of the `core.untrackedCache` |
| 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. |
Nguyễn Thái Ngọc Duy | 9e59724 | 2015-03-08 17:12:42 +0700 | [diff] [blame] | 195 | |
Christian Couder | eaab83d | 2016-01-24 16:28:16 +0100 | [diff] [blame] | 196 | --test-untracked-cache:: |
| 197 | Only perform tests on the working directory to make sure |
| 198 | untracked cache can be used. You have to manually enable |
Christian Couder | 435ec09 | 2016-01-27 07:58:05 +0100 | [diff] [blame] | 199 | untracked cache using `--untracked-cache` or |
| 200 | `--force-untracked-cache` or the `core.untrackedCache` |
| 201 | configuration variable afterwards if you really want to use |
| 202 | it. If a test fails the exit code is 1 and a message |
| 203 | explains what is not working as needed, otherwise the exit |
| 204 | code is 0 and OK is printed. |
Christian Couder | eaab83d | 2016-01-24 16:28:16 +0100 | [diff] [blame] | 205 | |
Nguyễn Thái Ngọc Duy | f64cb88 | 2015-03-08 17:12:43 +0700 | [diff] [blame] | 206 | --force-untracked-cache:: |
Christian Couder | 435ec09 | 2016-01-27 07:58:05 +0100 | [diff] [blame] | 207 | Same as `--untracked-cache`. Provided for backwards |
| 208 | compatibility with older versions of Git where |
| 209 | `--untracked-cache` used to imply `--test-untracked-cache` but |
| 210 | this option would enable the extension unconditionally. |
Nguyễn Thái Ngọc Duy | f64cb88 | 2015-03-08 17:12:43 +0700 | [diff] [blame] | 211 | |
Ben Peart | 780494b | 2017-09-22 12:35:41 -0400 | [diff] [blame] | 212 | --fsmonitor:: |
| 213 | --no-fsmonitor:: |
| 214 | Enable or disable files system monitor feature. These options |
| 215 | take effect whatever the value of the `core.fsmonitor` |
| 216 | configuration variable (see linkgit:git-config[1]). But a warning |
| 217 | is emitted when the change goes against the configured value, as |
| 218 | the configured value will take effect next time the index is |
| 219 | read and this will remove the intended effect of the option. |
| 220 | |
sean | e994004 | 2006-05-05 15:05:24 -0400 | [diff] [blame] | 221 | \--:: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 222 | Do not interpret any more arguments as options. |
| 223 | |
| 224 | <file>:: |
| 225 | Files to act on. |
Junio C Hamano | 5773c9f | 2005-10-29 14:32:56 -0700 | [diff] [blame] | 226 | Note that files beginning with '.' are discarded. This includes |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 227 | `./file` and `dir/./file`. If you don't want this, then use |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 228 | cleaner names. |
| 229 | The same applies to directories ending '/' and paths with '//' |
| 230 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 231 | USING --REFRESH |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 232 | --------------- |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 233 | `--refresh` does not calculate a new sha1 file or bring the index |
Martin Ågren | 7560f54 | 2017-08-23 19:49:35 +0200 | [diff] [blame] | 234 | up to date for mode/content changes. But what it *does* do is to |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 235 | "re-match" the stat information of a file with the index, so that you |
| 236 | can refresh the index for a file that hasn't been changed but where |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 237 | the stat entry is out of date. |
| 238 | |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 239 | For example, you'd want to do this after doing a 'git read-tree', to link |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 240 | up the stat index details with the proper files. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 241 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 242 | USING --CACHEINFO OR --INFO-ONLY |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 243 | -------------------------------- |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 244 | `--cacheinfo` is used to register a file that is not in the |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 245 | current working directory. This is useful for minimum-checkout |
| 246 | merging. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 247 | |
Elijah Newren | 388d0ff | 2018-08-08 13:28:07 -0700 | [diff] [blame] | 248 | To pretend you have a file at path with mode and sha1, say: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 249 | |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 250 | ---------------- |
Elijah Newren | 388d0ff | 2018-08-08 13:28:07 -0700 | [diff] [blame] | 251 | $ git update-index --add --cacheinfo <mode>,<sha1>,<path> |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 252 | ---------------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 253 | |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 254 | `--info-only` is used to register files without placing them in the object |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 255 | database. This is useful for status-only repositories. |
| 256 | |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 257 | Both `--cacheinfo` and `--info-only` behave similarly: the index is updated |
| 258 | but the object database isn't. `--cacheinfo` is useful when the object is |
| 259 | in the database but the file isn't available locally. `--info-only` is |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 260 | useful when the file is available, but you do not wish to update the |
| 261 | object database. |
| 262 | |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 263 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 264 | USING --INDEX-INFO |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 265 | ------------------ |
| 266 | |
| 267 | `--index-info` is a more powerful mechanism that lets you feed |
| 268 | multiple entry definitions from the standard input, and designed |
| 269 | specifically for scripts. It can take inputs of three formats: |
| 270 | |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 271 | . mode SP type SP sha1 TAB path |
| 272 | + |
Junio C Hamano | e05aa68 | 2018-08-08 14:35:18 -0700 | [diff] [blame] | 273 | This format is to stuff `git ls-tree` output into the index. |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 274 | |
| 275 | . mode SP sha1 SP stage TAB path |
| 276 | + |
| 277 | This format is to put higher order stages into the |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 278 | index file and matches 'git ls-files --stage' output. |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 279 | |
Junio C Hamano | e05aa68 | 2018-08-08 14:35:18 -0700 | [diff] [blame] | 280 | . mode SP sha1 TAB path |
| 281 | + |
| 282 | This format is no longer produced by any Git command, but is |
| 283 | and will continue to be supported by `update-index --index-info`. |
| 284 | |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 285 | To place a higher stage entry to the index, the path should |
| 286 | first be removed by feeding a mode=0 entry for the path, and |
| 287 | then feeding necessary input lines in the third format. |
| 288 | |
| 289 | For example, starting with this index: |
| 290 | |
| 291 | ------------ |
| 292 | $ git ls-files -s |
| 293 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz |
| 294 | ------------ |
| 295 | |
| 296 | you can feed the following input to `--index-info`: |
| 297 | |
| 298 | ------------ |
| 299 | $ git update-index --index-info |
| 300 | 0 0000000000000000000000000000000000000000 frotz |
| 301 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz |
| 302 | 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz |
| 303 | ------------ |
| 304 | |
| 305 | The first line of the input feeds 0 as the mode to remove the |
Thomas Ackermann | d5fa1f1 | 2013-04-15 19:49:04 +0200 | [diff] [blame] | 306 | path; the SHA-1 does not matter as long as it is well formatted. |
Junio C Hamano | d23748a | 2005-12-07 01:45:38 -0800 | [diff] [blame] | 307 | Then the second and third line feeds stage 1 and stage 2 entries |
| 308 | for that path. After the above, we would end up with this: |
| 309 | |
| 310 | ------------ |
| 311 | $ git ls-files -s |
| 312 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz |
| 313 | 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz |
| 314 | ------------ |
| 315 | |
| 316 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 317 | USING ``ASSUME UNCHANGED'' BIT |
Jonas Fonseca | bae777d | 2006-11-12 22:28:43 +0100 | [diff] [blame] | 318 | ------------------------------ |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 319 | |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 320 | Many operations in Git depend on your filesystem to have an |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 321 | efficient `lstat(2)` implementation, so that `st_mtime` |
| 322 | information for working tree files can be cheaply checked to see |
| 323 | if the file contents have changed from the version recorded in |
| 324 | the index file. Unfortunately, some filesystems have |
| 325 | inefficient `lstat(2)`. If your filesystem is one of them, you |
| 326 | can set "assume unchanged" bit to paths you have not changed to |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 327 | cause Git not to do this check. Note that setting this bit on a |
| 328 | path does not mean Git will check the contents of the file to |
| 329 | see if it has changed -- it makes Git to omit any checking and |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 330 | assume it has *not* changed. When you make changes to working |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 331 | tree files, you have to explicitly tell Git about it by dropping |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 332 | "assume unchanged" bit, either before or after you modify them. |
| 333 | |
| 334 | In order to set "assume unchanged" bit, use `--assume-unchanged` |
Stefan Naewe | acd6d7e | 2011-09-21 08:21:50 +0200 | [diff] [blame] | 335 | option. To unset, use `--no-assume-unchanged`. To see which files |
| 336 | have the "assume unchanged" bit set, use `git ls-files -v` |
| 337 | (see linkgit:git-ls-files[1]). |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 338 | |
| 339 | The command looks at `core.ignorestat` configuration variable. When |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 340 | this is true, paths updated with `git update-index paths...` and |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 341 | paths updated with other Git commands that update both index and |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 342 | working tree (e.g. 'git apply --index', 'git checkout-index -u', |
| 343 | and 'git read-tree -u') are automatically marked as "assume |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 344 | unchanged". Note that "assume unchanged" bit is *not* set if |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 345 | `git update-index --refresh` finds the working tree file matches |
| 346 | the index (use `git update-index --really-refresh` if you want |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 347 | to mark them as "assume unchanged"). |
| 348 | |
| 349 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 350 | EXAMPLES |
Bryan Larsen | df6e151 | 2005-07-08 16:52:12 -0700 | [diff] [blame] | 351 | -------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 352 | To update and refresh only the files already checked out: |
| 353 | |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 354 | ---------------- |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 355 | $ git checkout-index -n -f -a && git update-index --ignore-missing --refresh |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 356 | ---------------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 357 | |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 358 | On an inefficient filesystem with `core.ignorestat` set:: |
| 359 | + |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 360 | ------------ |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 361 | $ git update-index --really-refresh <1> |
| 362 | $ git update-index --no-assume-unchanged foo.c <2> |
| 363 | $ git diff --name-only <3> |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 364 | $ edit foo.c |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 365 | $ git diff --name-only <4> |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 366 | M foo.c |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 367 | $ git update-index foo.c <5> |
| 368 | $ git diff --name-only <6> |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 369 | $ edit foo.c |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 370 | $ git diff --name-only <7> |
| 371 | $ git update-index --no-assume-unchanged foo.c <8> |
| 372 | $ git diff --name-only <9> |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 373 | M foo.c |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 374 | ------------ |
| 375 | + |
| 376 | <1> forces lstat(2) to set "assume unchanged" bits for paths that match index. |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 377 | <2> mark the path to be edited. |
| 378 | <3> this does lstat(2) and finds index matches the path. |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 379 | <4> this does lstat(2) and finds index does *not* match the path. |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 380 | <5> registering the new version to index sets "assume unchanged" bit. |
| 381 | <6> and it is assumed unchanged. |
| 382 | <7> even after you edit it. |
| 383 | <8> you can tell about the change after the fact. |
| 384 | <9> now it checks with lstat(2) and finds it has been changed. |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 385 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 386 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 387 | SKIP-WORKTREE BIT |
Nguyễn Thái Ngọc Duy | 44a3691 | 2009-08-20 20:46:57 +0700 | [diff] [blame] | 388 | ----------------- |
| 389 | |
| 390 | Skip-worktree bit can be defined in one (long) sentence: When reading |
| 391 | an entry, if it is marked as skip-worktree, then Git pretends its |
| 392 | working directory version is up to date and read the index version |
| 393 | instead. |
| 394 | |
| 395 | To elaborate, "reading" means checking for file existence, reading |
| 396 | file attributes or file content. The working directory version may be |
| 397 | present or absent. If present, its content may match against the index |
| 398 | version or not. Writing is not affected by this bit, content safety |
| 399 | is still first priority. Note that Git _can_ update working directory |
| 400 | file, that is marked skip-worktree, if it is safe to do so (i.e. |
| 401 | working directory version matches index version) |
| 402 | |
| 403 | Although this bit looks similar to assume-unchanged bit, its goal is |
| 404 | different from assume-unchanged bit's. Skip-worktree also takes |
| 405 | precedence over assume-unchanged bit when both are set. |
| 406 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 407 | SPLIT INDEX |
Christian Couder | b460139 | 2017-03-06 10:42:03 +0100 | [diff] [blame] | 408 | ----------- |
| 409 | |
| 410 | This mode is designed for repositories with very large indexes, and |
| 411 | aims at reducing the time it takes to repeatedly write these indexes. |
| 412 | |
| 413 | In this mode, the index is split into two files, $GIT_DIR/index and |
| 414 | $GIT_DIR/sharedindex.<SHA-1>. Changes are accumulated in |
| 415 | $GIT_DIR/index, the split index, while the shared index file contains |
| 416 | all index entries and stays unchanged. |
| 417 | |
| 418 | All changes in the split index are pushed back to the shared index |
| 419 | file when the number of entries in the split index reaches a level |
| 420 | specified by the splitIndex.maxPercentChange config variable (see |
| 421 | linkgit:git-config[1]). |
| 422 | |
| 423 | Each time a new shared index file is created, the old shared index |
| 424 | files are deleted if their modification time is older than what is |
| 425 | specified by the splitIndex.sharedIndexExpire config variable (see |
| 426 | linkgit:git-config[1]). |
| 427 | |
| 428 | To avoid deleting a shared index file that is still used, its |
| 429 | modification time is updated to the current time everytime a new split |
| 430 | index based on the shared index file is either created or read from. |
| 431 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 432 | UNTRACKED CACHE |
Christian Couder | 435ec09 | 2016-01-27 07:58:05 +0100 | [diff] [blame] | 433 | --------------- |
| 434 | |
| 435 | This cache is meant to speed up commands that involve determining |
| 436 | untracked files such as `git status`. |
| 437 | |
| 438 | This feature works by recording the mtime of the working tree |
| 439 | directories and then omitting reading directories and stat calls |
| 440 | against files in those directories whose mtime hasn't changed. For |
| 441 | this to work the underlying operating system and file system must |
| 442 | change the `st_mtime` field of directories if files in the directory |
| 443 | are added, modified or deleted. |
| 444 | |
| 445 | You can test whether the filesystem supports that with the |
| 446 | `--test-untracked-cache` option. The `--untracked-cache` option used |
| 447 | to implicitly perform that test in older versions of Git, but that's |
| 448 | no longer the case. |
| 449 | |
| 450 | If you want to enable (or disable) this feature, it is easier to use |
| 451 | the `core.untrackedCache` configuration variable (see |
| 452 | linkgit:git-config[1]) than using the `--untracked-cache` option to |
| 453 | `git update-index` in each repository, especially if you want to do so |
| 454 | across all repositories you use, because you can set the configuration |
| 455 | variable to `true` (or `false`) in your `$HOME/.gitconfig` just once |
| 456 | and have it affect all repositories you touch. |
| 457 | |
| 458 | When the `core.untrackedCache` configuration variable is changed, the |
| 459 | untracked cache is added to or removed from the index the next time a |
| 460 | command reads the index; while when `--[no-|force-]untracked-cache` |
| 461 | are used, the untracked cache is immediately added to or removed from |
| 462 | the index. |
Nguyễn Thái Ngọc Duy | 44a3691 | 2009-08-20 20:46:57 +0700 | [diff] [blame] | 463 | |
Ævar Arnfjörð Bjarmason | 9b97869 | 2018-02-09 21:04:30 +0000 | [diff] [blame] | 464 | Before 2.17, the untracked cache had a bug where replacing a directory |
| 465 | with a symlink to another directory could cause it to incorrectly show |
| 466 | files tracked by git as untracked. See the "status: add a failing test |
| 467 | showing a core.untrackedCache bug" commit to git.git. A workaround for |
| 468 | that is (and this might work for other undiscovered bugs in the |
| 469 | future): |
| 470 | |
| 471 | ---------------- |
| 472 | $ git -c core.untrackedCache=false status |
| 473 | ---------------- |
| 474 | |
| 475 | This bug has also been shown to affect non-symlink cases of replacing |
| 476 | a directory with a file when it comes to the internal structures of |
| 477 | the untracked cache, but no case has been reported where this resulted in |
| 478 | wrong "git status" output. |
| 479 | |
Ævar Arnfjörð Bjarmason | 7bf0be7 | 2018-02-09 21:04:31 +0000 | [diff] [blame] | 480 | There are also cases where existing indexes written by git versions |
| 481 | before 2.17 will reference directories that don't exist anymore, |
| 482 | potentially causing many "could not open directory" warnings to be |
| 483 | printed on "git status". These are new warnings for existing issues |
| 484 | that were previously silently discarded. |
| 485 | |
| 486 | As with the bug described above the solution is to one-off do a "git |
| 487 | status" run with `core.untrackedCache=false` to flush out the leftover |
| 488 | bad data. |
| 489 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 490 | FILE SYSTEM MONITOR |
Ben Peart | 780494b | 2017-09-22 12:35:41 -0400 | [diff] [blame] | 491 | ------------------- |
| 492 | |
| 493 | This feature is intended to speed up git operations for repos that have |
| 494 | large working directories. |
| 495 | |
| 496 | It enables git to work together with a file system monitor (see the |
| 497 | "fsmonitor-watchman" section of linkgit:githooks[5]) that can |
| 498 | inform it as to what files have been modified. This enables git to avoid |
| 499 | having to lstat() every file to find modified files. |
| 500 | |
| 501 | When used in conjunction with the untracked cache, it can further improve |
| 502 | performance by avoiding the cost of scanning the entire working directory |
| 503 | looking for new files. |
| 504 | |
| 505 | If you want to enable (or disable) this feature, it is easier to use |
| 506 | the `core.fsmonitor` configuration variable (see |
| 507 | linkgit:git-config[1]) than using the `--fsmonitor` option to |
| 508 | `git update-index` in each repository, especially if you want to do so |
| 509 | across all repositories you use, because you can set the configuration |
Ben Peart | 4ccf461 | 2018-02-14 10:41:30 -0500 | [diff] [blame] | 510 | variable in your `$HOME/.gitconfig` just once and have it affect all |
| 511 | repositories you touch. |
Ben Peart | 780494b | 2017-09-22 12:35:41 -0400 | [diff] [blame] | 512 | |
| 513 | When the `core.fsmonitor` configuration variable is changed, the |
| 514 | file system monitor is added to or removed from the index the next time |
| 515 | a command reads the index. When `--[no-]fsmonitor` are used, the file |
| 516 | system monitor is immediately added to or removed from the index. |
| 517 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 518 | CONFIGURATION |
Junio C Hamano | 5773c9f | 2005-10-29 14:32:56 -0700 | [diff] [blame] | 519 | ------------- |
| 520 | |
| 521 | The command honors `core.filemode` configuration variable. If |
Štěpán Němec | 466d1f1 | 2009-11-10 19:11:51 +0100 | [diff] [blame] | 522 | your repository is on a filesystem whose executable bits are |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 523 | unreliable, this should be set to 'false' (see linkgit:git-config[1]). |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 524 | This causes the command to ignore differences in file modes recorded |
| 525 | in the index and the file mode on the filesystem if they differ only on |
Junio C Hamano | 5773c9f | 2005-10-29 14:32:56 -0700 | [diff] [blame] | 526 | executable bit. On such an unfortunate filesystem, you may |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 527 | need to use 'git update-index --chmod='. |
Junio C Hamano | 5773c9f | 2005-10-29 14:32:56 -0700 | [diff] [blame] | 528 | |
Johannes Sixt | 78a8d64 | 2007-03-02 22:11:30 +0100 | [diff] [blame] | 529 | Quite similarly, if `core.symlinks` configuration variable is set |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 530 | to 'false' (see linkgit:git-config[1]), symbolic links are checked out |
Johannes Sixt | 78a8d64 | 2007-03-02 22:11:30 +0100 | [diff] [blame] | 531 | as plain files, and this command does not modify a recorded file mode |
| 532 | from symbolic link to regular file. |
| 533 | |
Junio C Hamano | f9666ad | 2006-02-12 01:48:47 -0800 | [diff] [blame] | 534 | The command looks at `core.ignorestat` configuration variable. See |
| 535 | 'Using "assume unchanged" bit' section above. |
| 536 | |
Alex Riesen | 1ce4790 | 2008-07-28 08:31:28 +0200 | [diff] [blame] | 537 | The command also looks at `core.trustctime` configuration variable. |
| 538 | It can be useful when the inode change time is regularly modified by |
| 539 | something outside Git (file system crawlers and backup systems use |
| 540 | ctime for marking files processed) (see linkgit:git-config[1]). |
| 541 | |
Christian Couder | 435ec09 | 2016-01-27 07:58:05 +0100 | [diff] [blame] | 542 | The untracked cache extension can be enabled by the |
| 543 | `core.untrackedCache` configuration variable (see |
| 544 | linkgit:git-config[1]). |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 545 | |
Junio C Hamano | 56ae8df | 2008-05-28 16:55:27 -0700 | [diff] [blame] | 546 | SEE ALSO |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 547 | -------- |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 548 | linkgit:git-config[1], |
Stefan Naewe | acd6d7e | 2011-09-21 08:21:50 +0200 | [diff] [blame] | 549 | linkgit:git-add[1], |
| 550 | linkgit:git-ls-files[1] |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 551 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 552 | GIT |
| 553 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 554 | Part of the linkgit:git[1] suite |