]>
Commit | Line | Data |
---|---|---|
215a7ad1 | 1 | git-update-index(1) |
2cf565c5 | 2 | =================== |
2cf565c5 DG |
3 | |
4 | NAME | |
5 | ---- | |
215a7ad1 | 6 | git-update-index - Modifies the index or directory cache |
2cf565c5 DG |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
215a7ad1 | 11 | 'git-update-index' |
14470c0d CS |
12 | [--add] [--remove | --force-remove] [--replace] |
13 | [--refresh [-q] [--unmerged] [--ignore-missing]] | |
2cf565c5 | 14 | [--cacheinfo <mode> <object> <file>]\* |
5773c9f2 | 15 | [--chmod=(+|-)x] |
14470c0d CS |
16 | [--info-only] [--index-info] |
17 | [-z] [--stdin] | |
18 | [--verbose] | |
2cf565c5 DG |
19 | [--] [<file>]\* |
20 | ||
21 | DESCRIPTION | |
22 | ----------- | |
23 | Modifies the index or directory cache. Each file mentioned is updated | |
5f3aa197 | 24 | into the index and any 'unmerged' or 'needs updating' state is |
2cf565c5 DG |
25 | cleared. |
26 | ||
215a7ad1 | 27 | The way "git-update-index" handles files it is told about can be modified |
2cf565c5 DG |
28 | using the various options: |
29 | ||
30 | OPTIONS | |
31 | ------- | |
32 | --add:: | |
5f3aa197 | 33 | If a specified file isn't in the index already then it's |
2cf565c5 DG |
34 | added. |
35 | Default behaviour is to ignore new files. | |
36 | ||
37 | --remove:: | |
5f3aa197 | 38 | If a specified file is in the index but is missing then it's |
2cf565c5 DG |
39 | removed. |
40 | Default behaviour is to ignore removed file. | |
41 | ||
42 | --refresh:: | |
5f3aa197 | 43 | Looks at the current index and checks to see if merges or |
2cf565c5 DG |
44 | updates are needed by checking stat() information. |
45 | ||
14470c0d | 46 | -q:: |
5f3aa197 | 47 | Quiet. If --refresh finds that the index needs an update, the |
14470c0d CS |
48 | default behavior is to error out. This option makes |
49 | git-update-index continue anyway. | |
50 | ||
51 | --unmerged:: | |
5f3aa197 | 52 | If --refresh finds unmerged changes in the index, the default |
14470c0d CS |
53 | behavior is to error out. This option makes git-update-index |
54 | continue anyway. | |
55 | ||
2cf565c5 DG |
56 | --ignore-missing:: |
57 | Ignores missing files during a --refresh | |
58 | ||
59 | --cacheinfo <mode> <object> <path>:: | |
5f3aa197 | 60 | Directly insert the specified info into the index. |
2cf565c5 | 61 | |
14470c0d | 62 | --index-info:: |
7acab8f1 | 63 | Read index information from stdin. |
14470c0d CS |
64 | |
65 | --chmod=(+|-)x:: | |
66 | Set the execute permissions on the updated files. | |
67 | ||
df6e1516 BL |
68 | --info-only:: |
69 | Do not create objects in the object database for all | |
70 | <file> arguments that follow this flag; just insert | |
5f3aa197 | 71 | their object IDs into the index. |
df6e1516 | 72 | |
2cf565c5 DG |
73 | --force-remove:: |
74 | Remove the file from the index even when the working directory | |
9b63f501 | 75 | still has such a file. (Implies --remove.) |
2cf565c5 DG |
76 | |
77 | --replace:: | |
78 | By default, when a file `path` exists in the index, | |
215a7ad1 | 79 | git-update-index refuses an attempt to add `path/file`. |
2cf565c5 DG |
80 | Similarly if a file `path/file` exists, a file `path` |
81 | cannot be added. With --replace flag, existing entries | |
82 | that conflicts with the entry being added are | |
83 | automatically removed with warning messages. | |
84 | ||
1f7f99de JH |
85 | --stdin:: |
86 | Instead of taking list of paths from the command line, | |
87 | read list of paths from the standard input. Paths are | |
88 | separated by LF (i.e. one path per line) by default. | |
89 | ||
14470c0d CS |
90 | --verbose:: |
91 | Report what is being added and removed from index. | |
92 | ||
1f7f99de JH |
93 | -z:: |
94 | Only meaningful with `--stdin`; paths are separated with | |
95 | NUL character instead of LF. | |
96 | ||
2cf565c5 DG |
97 | --:: |
98 | Do not interpret any more arguments as options. | |
99 | ||
100 | <file>:: | |
101 | Files to act on. | |
5773c9f2 | 102 | Note that files beginning with '.' are discarded. This includes |
2cf565c5 DG |
103 | `./file` and `dir/./file`. If you don't want this, then use |
104 | cleaner names. | |
105 | The same applies to directories ending '/' and paths with '//' | |
106 | ||
107 | Using --refresh | |
108 | --------------- | |
5f3aa197 | 109 | '--refresh' does not calculate a new sha1 file or bring the index |
2cf565c5 | 110 | up-to-date for mode/content changes. But what it *does* do is to |
5f3aa197 LS |
111 | "re-match" the stat information of a file with the index, so that you |
112 | can refresh the index for a file that hasn't been changed but where | |
2cf565c5 DG |
113 | the stat entry is out of date. |
114 | ||
115 | For example, you'd want to do this after doing a "git-read-tree", to link | |
5f3aa197 | 116 | up the stat index details with the proper files. |
2cf565c5 | 117 | |
df6e1516 BL |
118 | Using --cacheinfo or --info-only |
119 | -------------------------------- | |
120 | '--cacheinfo' is used to register a file that is not in the | |
121 | current working directory. This is useful for minimum-checkout | |
122 | merging. | |
123 | ||
df8baa42 | 124 | To pretend you have a file with mode and sha1 at path, say: |
2cf565c5 | 125 | |
61f693bd JL |
126 | ---------------- |
127 | $ git-update-index --cacheinfo mode sha1 path | |
128 | ---------------- | |
2cf565c5 | 129 | |
df6e1516 BL |
130 | '--info-only' is used to register files without placing them in the object |
131 | database. This is useful for status-only repositories. | |
2cf565c5 | 132 | |
df6e1516 BL |
133 | Both '--cacheinfo' and '--info-only' behave similarly: the index is updated |
134 | but the object database isn't. '--cacheinfo' is useful when the object is | |
135 | in the database but the file isn't available locally. '--info-only' is | |
136 | useful when the file is available, but you do not wish to update the | |
137 | object database. | |
138 | ||
d23748a6 JH |
139 | |
140 | Using --index-info | |
141 | ------------------ | |
142 | ||
143 | `--index-info` is a more powerful mechanism that lets you feed | |
144 | multiple entry definitions from the standard input, and designed | |
145 | specifically for scripts. It can take inputs of three formats: | |
146 | ||
147 | . mode SP sha1 TAB path | |
148 | + | |
149 | The first format is what "git-apply --index-info" | |
150 | reports, and used to reconstruct a partial tree | |
151 | that is used for phony merge base tree when falling | |
152 | back on 3-way merge. | |
153 | ||
154 | . mode SP type SP sha1 TAB path | |
155 | + | |
156 | The second format is to stuff git-ls-tree output | |
157 | into the index file. | |
158 | ||
159 | . mode SP sha1 SP stage TAB path | |
160 | + | |
161 | This format is to put higher order stages into the | |
162 | index file and matches git-ls-files --stage output. | |
163 | ||
164 | To place a higher stage entry to the index, the path should | |
165 | first be removed by feeding a mode=0 entry for the path, and | |
166 | then feeding necessary input lines in the third format. | |
167 | ||
168 | For example, starting with this index: | |
169 | ||
170 | ------------ | |
171 | $ git ls-files -s | |
172 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz | |
173 | ------------ | |
174 | ||
175 | you can feed the following input to `--index-info`: | |
176 | ||
177 | ------------ | |
178 | $ git update-index --index-info | |
179 | 0 0000000000000000000000000000000000000000 frotz | |
180 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz | |
181 | 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz | |
182 | ------------ | |
183 | ||
184 | The first line of the input feeds 0 as the mode to remove the | |
185 | path; the SHA1 does not matter as long as it is well formatted. | |
186 | Then the second and third line feeds stage 1 and stage 2 entries | |
187 | for that path. After the above, we would end up with this: | |
188 | ||
189 | ------------ | |
190 | $ git ls-files -s | |
191 | 100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz | |
192 | 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz | |
193 | ------------ | |
194 | ||
195 | ||
df6e1516 BL |
196 | Examples |
197 | -------- | |
2cf565c5 DG |
198 | To update and refresh only the files already checked out: |
199 | ||
61f693bd JL |
200 | ---------------- |
201 | $ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh | |
202 | ---------------- | |
2cf565c5 DG |
203 | |
204 | ||
5773c9f2 JH |
205 | Configuration |
206 | ------------- | |
207 | ||
208 | The command honors `core.filemode` configuration variable. If | |
209 | your repository is on an filesystem whose executable bits are | |
61f693bd JL |
210 | unreliable, this should be set to 'false' (see gitlink:git-repo-config[1]). |
211 | This causes the command to ignore differences in file modes recorded | |
212 | in the index and the file mode on the filesystem if they differ only on | |
5773c9f2 JH |
213 | executable bit. On such an unfortunate filesystem, you may |
214 | need to use `git-update-index --chmod=`. | |
215 | ||
61f693bd JL |
216 | |
217 | See Also | |
218 | -------- | |
219 | gitlink:git-repo-config[1] | |
220 | ||
221 | ||
2cf565c5 DG |
222 | Author |
223 | ------ | |
224 | Written by Linus Torvalds <torvalds@osdl.org> | |
225 | ||
226 | Documentation | |
227 | -------------- | |
228 | Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. | |
229 | ||
230 | GIT | |
231 | --- | |
a7154e91 | 232 | Part of the gitlink:git[7] suite |
2cf565c5 | 233 |