]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-update-index.txt
diff options: Introduce --ignore-submodules
[thirdparty/git.git] / Documentation / git-update-index.txt
CommitLineData
215a7ad1 1git-update-index(1)
2cf565c5 2===================
2cf565c5
DG
3
4NAME
5----
c3f0baac 6git-update-index - Register file contents in the working tree to the index
2cf565c5
DG
7
8
9SYNOPSIS
10--------
f9666adf 11[verse]
215a7ad1 12'git-update-index'
de5f2bf3
MK
13 [--add] [--remove | --force-remove] [--replace]
14 [--refresh] [-q] [--unmerged] [--ignore-missing]
2cf565c5 15 [--cacheinfo <mode> <object> <file>]\*
5773c9f2 16 [--chmod=(+|-)x]
f9666adf 17 [--assume-unchanged | --no-assume-unchanged]
7099c9c7 18 [--really-refresh] [--unresolve] [--again | -g]
14470c0d
CS
19 [--info-only] [--index-info]
20 [-z] [--stdin]
21 [--verbose]
2cf565c5
DG
22 [--] [<file>]\*
23
24DESCRIPTION
25-----------
26Modifies the index or directory cache. Each file mentioned is updated
5f3aa197 27into the index and any 'unmerged' or 'needs updating' state is
2cf565c5
DG
28cleared.
29
5162e697 30See also linkgit:git-add[1] for a more user-friendly way to do some of
e701ccc3
MM
31the most common operations on the index.
32
215a7ad1 33The way "git-update-index" handles files it is told about can be modified
2cf565c5
DG
34using the various options:
35
36OPTIONS
37-------
38--add::
5f3aa197 39 If a specified file isn't in the index already then it's
2cf565c5
DG
40 added.
41 Default behaviour is to ignore new files.
42
43--remove::
5f3aa197 44 If a specified file is in the index but is missing then it's
2cf565c5 45 removed.
abda1ef5 46 Default behavior is to ignore removed file.
2cf565c5
DG
47
48--refresh::
5f3aa197 49 Looks at the current index and checks to see if merges or
2cf565c5
DG
50 updates are needed by checking stat() information.
51
14470c0d 52-q::
5f3aa197 53 Quiet. If --refresh finds that the index needs an update, the
14470c0d
CS
54 default behavior is to error out. This option makes
55 git-update-index continue anyway.
56
57--unmerged::
5f3aa197 58 If --refresh finds unmerged changes in the index, the default
a6080a0a 59 behavior is to error out. This option makes git-update-index
14470c0d
CS
60 continue anyway.
61
2cf565c5
DG
62--ignore-missing::
63 Ignores missing files during a --refresh
64
65--cacheinfo <mode> <object> <path>::
5f3aa197 66 Directly insert the specified info into the index.
a6080a0a 67
14470c0d 68--index-info::
7acab8f1 69 Read index information from stdin.
14470c0d
CS
70
71--chmod=(+|-)x::
a6080a0a 72 Set the execute permissions on the updated files.
14470c0d 73
f9666adf
JH
74--assume-unchanged, --no-assume-unchanged::
75 When these flags are specified, the object name recorded
76 for the paths are not updated. Instead, these options
77 sets and unsets the "assume unchanged" bit for the
78 paths. When the "assume unchanged" bit is on, git stops
79 checking the working tree files for possible
80 modifications, so you need to manually unset the bit to
81 tell git when you change the working tree file. This is
82 sometimes helpful when working with a big project on a
83 filesystem that has very slow lstat(2) system call
84 (e.g. cifs).
85
7099c9c7 86--again, -g::
83e77a25
JH
87 Runs `git-update-index` itself on the paths whose index
88 entries are different from those from the `HEAD` commit.
89
060729dd
MK
90--unresolve::
91 Restores the 'unmerged' or 'needs updating' state of a
92 file during a merge if it was cleared by accident.
93
df6e1516
BL
94--info-only::
95 Do not create objects in the object database for all
96 <file> arguments that follow this flag; just insert
5f3aa197 97 their object IDs into the index.
df6e1516 98
2cf565c5
DG
99--force-remove::
100 Remove the file from the index even when the working directory
9b63f501 101 still has such a file. (Implies --remove.)
2cf565c5
DG
102
103--replace::
104 By default, when a file `path` exists in the index,
215a7ad1 105 git-update-index refuses an attempt to add `path/file`.
2cf565c5
DG
106 Similarly if a file `path/file` exists, a file `path`
107 cannot be added. With --replace flag, existing entries
108 that conflicts with the entry being added are
109 automatically removed with warning messages.
110
1f7f99de
JH
111--stdin::
112 Instead of taking list of paths from the command line,
113 read list of paths from the standard input. Paths are
114 separated by LF (i.e. one path per line) by default.
115
14470c0d
CS
116--verbose::
117 Report what is being added and removed from index.
118
1f7f99de
JH
119-z::
120 Only meaningful with `--stdin`; paths are separated with
121 NUL character instead of LF.
122
e994004f 123\--::
2cf565c5
DG
124 Do not interpret any more arguments as options.
125
126<file>::
127 Files to act on.
5773c9f2 128 Note that files beginning with '.' are discarded. This includes
a6080a0a 129 `./file` and `dir/./file`. If you don't want this, then use
2cf565c5
DG
130 cleaner names.
131 The same applies to directories ending '/' and paths with '//'
132
133Using --refresh
134---------------
5f3aa197 135'--refresh' does not calculate a new sha1 file or bring the index
2cf565c5 136up-to-date for mode/content changes. But what it *does* do is to
5f3aa197
LS
137"re-match" the stat information of a file with the index, so that you
138can refresh the index for a file that hasn't been changed but where
2cf565c5
DG
139the stat entry is out of date.
140
141For example, you'd want to do this after doing a "git-read-tree", to link
5f3aa197 142up the stat index details with the proper files.
2cf565c5 143
df6e1516
BL
144Using --cacheinfo or --info-only
145--------------------------------
146'--cacheinfo' is used to register a file that is not in the
147current working directory. This is useful for minimum-checkout
148merging.
149
df8baa42 150To pretend you have a file with mode and sha1 at path, say:
2cf565c5 151
61f693bd
JL
152----------------
153$ git-update-index --cacheinfo mode sha1 path
154----------------
2cf565c5 155
df6e1516
BL
156'--info-only' is used to register files without placing them in the object
157database. This is useful for status-only repositories.
2cf565c5 158
df6e1516
BL
159Both '--cacheinfo' and '--info-only' behave similarly: the index is updated
160but the object database isn't. '--cacheinfo' is useful when the object is
161in the database but the file isn't available locally. '--info-only' is
162useful when the file is available, but you do not wish to update the
163object database.
164
d23748a6
JH
165
166Using --index-info
167------------------
168
169`--index-info` is a more powerful mechanism that lets you feed
170multiple entry definitions from the standard input, and designed
171specifically for scripts. It can take inputs of three formats:
172
173 . mode SP sha1 TAB path
174+
175The first format is what "git-apply --index-info"
176reports, and used to reconstruct a partial tree
177that is used for phony merge base tree when falling
178back on 3-way merge.
179
180 . mode SP type SP sha1 TAB path
181+
182The second format is to stuff git-ls-tree output
183into the index file.
184
185 . mode SP sha1 SP stage TAB path
186+
187This format is to put higher order stages into the
188index file and matches git-ls-files --stage output.
189
190To place a higher stage entry to the index, the path should
191first be removed by feeding a mode=0 entry for the path, and
192then feeding necessary input lines in the third format.
193
194For example, starting with this index:
195
196------------
197$ git ls-files -s
198100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz
199------------
200
201you can feed the following input to `--index-info`:
202
203------------
204$ git update-index --index-info
2050 0000000000000000000000000000000000000000 frotz
206100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz
207100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz
208------------
209
210The first line of the input feeds 0 as the mode to remove the
211path; the SHA1 does not matter as long as it is well formatted.
212Then the second and third line feeds stage 1 and stage 2 entries
213for that path. After the above, we would end up with this:
214
215------------
216$ git ls-files -s
217100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz
218100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz
219------------
220
221
bae777db
JF
222Using ``assume unchanged'' bit
223------------------------------
f9666adf
JH
224
225Many operations in git depend on your filesystem to have an
226efficient `lstat(2)` implementation, so that `st_mtime`
227information for working tree files can be cheaply checked to see
228if the file contents have changed from the version recorded in
229the index file. Unfortunately, some filesystems have
230inefficient `lstat(2)`. If your filesystem is one of them, you
231can set "assume unchanged" bit to paths you have not changed to
232cause git not to do this check. Note that setting this bit on a
233path does not mean git will check the contents of the file to
234see if it has changed -- it makes git to omit any checking and
235assume it has *not* changed. When you make changes to working
236tree files, you have to explicitly tell git about it by dropping
237"assume unchanged" bit, either before or after you modify them.
238
239In order to set "assume unchanged" bit, use `--assume-unchanged`
240option. To unset, use `--no-assume-unchanged`.
241
242The command looks at `core.ignorestat` configuration variable. When
243this is true, paths updated with `git-update-index paths...` and
244paths updated with other git commands that update both index and
245working tree (e.g. `git-apply --index`, `git-checkout-index -u`,
246and `git-read-tree -u`) are automatically marked as "assume
247unchanged". Note that "assume unchanged" bit is *not* set if
248`git-update-index --refresh` finds the working tree file matches
249the index (use `git-update-index --really-refresh` if you want
250to mark them as "assume unchanged").
251
252
df6e1516
BL
253Examples
254--------
2cf565c5
DG
255To update and refresh only the files already checked out:
256
61f693bd
JL
257----------------
258$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
259----------------
2cf565c5 260
48aeecdc
SE
261On an inefficient filesystem with `core.ignorestat` set::
262+
f9666adf 263------------
48aeecdc
SE
264$ git update-index --really-refresh <1>
265$ git update-index --no-assume-unchanged foo.c <2>
266$ git diff --name-only <3>
f9666adf 267$ edit foo.c
48aeecdc 268$ git diff --name-only <4>
f9666adf 269M foo.c
48aeecdc
SE
270$ git update-index foo.c <5>
271$ git diff --name-only <6>
f9666adf 272$ edit foo.c
48aeecdc
SE
273$ git diff --name-only <7>
274$ git update-index --no-assume-unchanged foo.c <8>
275$ git diff --name-only <9>
f9666adf 276M foo.c
48aeecdc
SE
277------------
278+
279<1> forces lstat(2) to set "assume unchanged" bits for paths that match index.
f9666adf
JH
280<2> mark the path to be edited.
281<3> this does lstat(2) and finds index matches the path.
48aeecdc 282<4> this does lstat(2) and finds index does *not* match the path.
f9666adf
JH
283<5> registering the new version to index sets "assume unchanged" bit.
284<6> and it is assumed unchanged.
285<7> even after you edit it.
286<8> you can tell about the change after the fact.
287<9> now it checks with lstat(2) and finds it has been changed.
f9666adf 288
2cf565c5 289
5773c9f2
JH
290Configuration
291-------------
292
293The command honors `core.filemode` configuration variable. If
294your repository is on an filesystem whose executable bits are
5162e697 295unreliable, this should be set to 'false' (see linkgit:git-config[1]).
61f693bd
JL
296This causes the command to ignore differences in file modes recorded
297in the index and the file mode on the filesystem if they differ only on
5773c9f2
JH
298executable bit. On such an unfortunate filesystem, you may
299need to use `git-update-index --chmod=`.
300
78a8d641 301Quite similarly, if `core.symlinks` configuration variable is set
5162e697 302to 'false' (see linkgit:git-config[1]), symbolic links are checked out
78a8d641
JS
303as plain files, and this command does not modify a recorded file mode
304from symbolic link to regular file.
305
f9666adf
JH
306The command looks at `core.ignorestat` configuration variable. See
307'Using "assume unchanged" bit' section above.
308
61f693bd
JL
309
310See Also
311--------
5162e697
DM
312linkgit:git-config[1],
313linkgit:git-add[1]
61f693bd
JL
314
315
2cf565c5
DG
316Author
317------
318Written by Linus Torvalds <torvalds@osdl.org>
319
320Documentation
321--------------
322Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
323
324GIT
325---
5162e697 326Part of the linkgit:git[7] suite