make some more strings translatable
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-add.html.xml
blob071367dc1fafc2df5549bdefd662f3037977fd46
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-add(1)">\r
5 <articleinfo>\r
6     <title>git-add(1)</title>\r
7         <indexterm>\r
8                 <primary>git-add(1)</primary>\r
9         </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-add - Add file contents to the index</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git add</emphasis> [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]\r
19           [--all | [--update | -u]] [--intent-to-add | -N]\r
20           [--refresh] [--ignore-errors] [--] &lt;filepattern&gt;&#8230;</literallayout>\r
21 </blockquote>\r
22 </simplesect>\r
23 <simplesect id="_description">\r
24 <title>DESCRIPTION</title>\r
25 <simpara>This command adds the current content of new or modified files to the\r
26 index, thus staging that content for inclusion in the next commit.</simpara>\r
27 <simpara>The "index" holds a snapshot of the content of the working tree, and it\r
28 is this snapshot that is taken as the contents of the next commit.  Thus\r
29 after making any changes to the working directory, and before running\r
30 the commit command, you must use the <emphasis>add</emphasis> command to add any new or\r
31 modified files to the index.</simpara>\r
32 <simpara>This command can be performed multiple times before a commit.  It only\r
33 adds the content of the specified file(s) at the time the add command is\r
34 run; if you want subsequent changes included in the next commit, then\r
35 you must run <emphasis>git add</emphasis> again to add the new content to the index.</simpara>\r
36 <simpara>The <emphasis>git status</emphasis> command can be used to obtain a summary of which\r
37 files have changes that are staged for the next commit.</simpara>\r
38 <simpara>The <emphasis>git add</emphasis> command will not add ignored files by default.  If any\r
39 ignored files were explicitly specified on the command line, <emphasis>git add</emphasis>\r
40 will fail with a list of ignored files.  Ignored files reached by\r
41 directory recursion or filename globbing performed by Git (quote your\r
42 globs before the shell) will be silently ignored.  The <emphasis>add</emphasis> command can\r
43 be used to add ignored files with the <literal>-f</literal> (force) option.</simpara>\r
44 <simpara>Please see <xref linkend="git-commit(1)"/> for alternative ways to add content to a\r
45 commit.</simpara>\r
46 </simplesect>\r
47 <simplesect id="_options">\r
48 <title>OPTIONS</title>\r
49 <variablelist>\r
50 <varlistentry>\r
51 <term>\r
52 &lt;filepattern&gt;&#8230;\r
53 </term>\r
54 <listitem>\r
55 <simpara>\r
56         Files to add content from.  Fileglobs (e.g. <literal>*.c</literal>) can\r
57         be given to add all matching files.  Also a\r
58         leading directory name (e.g. <literal>dir</literal> to add <literal>dir/file1</literal>\r
59         and <literal>dir/file2</literal>) can be given to add all files in the\r
60         directory, recursively.\r
61 </simpara>\r
62 </listitem>\r
63 </varlistentry>\r
64 <varlistentry>\r
65 <term>\r
66 -n\r
67 </term>\r
68 <term>\r
69 --dry-run\r
70 </term>\r
71 <listitem>\r
72 <simpara>\r
73         Don&#8217;t actually add the file(s), just show if they exist.\r
74 </simpara>\r
75 </listitem>\r
76 </varlistentry>\r
77 <varlistentry>\r
78 <term>\r
79 -v\r
80 </term>\r
81 <term>\r
82 --verbose\r
83 </term>\r
84 <listitem>\r
85 <simpara>\r
86         Be verbose.\r
87 </simpara>\r
88 </listitem>\r
89 </varlistentry>\r
90 <varlistentry>\r
91 <term>\r
92 -f\r
93 </term>\r
94 <term>\r
95 --force\r
96 </term>\r
97 <listitem>\r
98 <simpara>\r
99         Allow adding otherwise ignored files.\r
100 </simpara>\r
101 </listitem>\r
102 </varlistentry>\r
103 <varlistentry>\r
104 <term>\r
105 -i\r
106 </term>\r
107 <term>\r
108 --interactive\r
109 </term>\r
110 <listitem>\r
111 <simpara>\r
112         Add modified contents in the working tree interactively to\r
113         the index. Optional path arguments may be supplied to limit\r
114         operation to a subset of the working tree. See &#8220;Interactive\r
115         mode&#8221; for details.\r
116 </simpara>\r
117 </listitem>\r
118 </varlistentry>\r
119 <varlistentry>\r
120 <term>\r
121 -p\r
122 </term>\r
123 <term>\r
124 --patch\r
125 </term>\r
126 <listitem>\r
127 <simpara>\r
128         Similar to Interactive mode but the initial command loop is\r
129         bypassed and the <emphasis>patch</emphasis> subcommand is invoked using each of\r
130         the specified filepatterns before exiting.\r
131 </simpara>\r
132 </listitem>\r
133 </varlistentry>\r
134 <varlistentry>\r
135 <term>\r
136 -u\r
137 </term>\r
138 <term>\r
139 --update\r
140 </term>\r
141 <listitem>\r
142 <simpara>\r
143         Update only files that git already knows about, staging modified\r
144         content for commit and marking deleted files for removal. This\r
145         is similar\r
146         to what "git commit -a" does in preparation for making a commit,\r
147         except that the update is limited to paths specified on the\r
148         command line. If no paths are specified, all tracked files in the\r
149         current directory and its subdirectories are updated.\r
150 </simpara>\r
151 </listitem>\r
152 </varlistentry>\r
153 <varlistentry>\r
154 <term>\r
155 -A\r
156 </term>\r
157 <term>\r
158 --all\r
159 </term>\r
160 <listitem>\r
161 <simpara>\r
162         Update files that git already knows about (same as <emphasis>--update</emphasis>)\r
163         and add all untracked files that are not ignored by <emphasis>.gitignore</emphasis>\r
164         mechanism.\r
165 </simpara>\r
166 </listitem>\r
167 </varlistentry>\r
168 <varlistentry>\r
169 <term>\r
170 -N\r
171 </term>\r
172 <term>\r
173 --intent-to-add\r
174 </term>\r
175 <listitem>\r
176 <simpara>\r
177         Record only the fact that the path will be added later. An entry\r
178         for the path is placed in the index with no content. This is\r
179         useful for, among other things, showing the unstaged content of\r
180         such files with <emphasis>git diff</emphasis> and committing them with <emphasis>git commit\r
181         -a</emphasis>.\r
182 </simpara>\r
183 </listitem>\r
184 </varlistentry>\r
185 <varlistentry>\r
186 <term>\r
187 --refresh\r
188 </term>\r
189 <listitem>\r
190 <simpara>\r
191         Don&#8217;t add the file(s), but only refresh their stat()\r
192         information in the index.\r
193 </simpara>\r
194 </listitem>\r
195 </varlistentry>\r
196 <varlistentry>\r
197 <term>\r
198 --ignore-errors\r
199 </term>\r
200 <listitem>\r
201 <simpara>\r
202         If some files could not be added because of errors indexing\r
203         them, do not abort the operation, but continue adding the\r
204         others. The command shall still exit with non-zero status.\r
205 </simpara>\r
206 </listitem>\r
207 </varlistentry>\r
208 <varlistentry>\r
209 <term>\r
210 --\r
211 </term>\r
212 <listitem>\r
213 <simpara>\r
214         This option can be used to separate command-line options from\r
215         the list of files, (useful when filenames might be mistaken\r
216         for command-line options).\r
217 </simpara>\r
218 </listitem>\r
219 </varlistentry>\r
220 </variablelist>\r
221 </simplesect>\r
222 <simplesect id="_configuration">\r
223 <title>Configuration</title>\r
224 <simpara>The optional configuration variable <emphasis>core.excludesfile</emphasis> indicates a path to a\r
225 file containing patterns of file names to exclude from git-add, similar to\r
226 $GIT_DIR/info/exclude.  Patterns in the exclude file are used in addition to\r
227 those in info/exclude.  See <xref linkend="gitrepository-layout(5)"/>.</simpara>\r
228 </simplesect>\r
229 <simplesect id="_examples">\r
230 <title>EXAMPLES</title>\r
231 <itemizedlist>\r
232 <listitem>\r
233 <simpara>\r
234 Adds content from all <literal>\*.txt</literal> files under <literal>Documentation</literal> directory\r
235 and its subdirectories:\r
236 </simpara>\r
237 <literallayout>$ git add Documentation/\\*.txt</literallayout>\r
238 <simpara>Note that the asterisk <literal>\*</literal> is quoted from the shell in this\r
239 example; this lets the command to include the files from\r
240 subdirectories of <literal>Documentation/</literal> directory.</simpara>\r
241 </listitem>\r
242 <listitem>\r
243 <simpara>\r
244 Considers adding content from all git-*.sh scripts:\r
245 </simpara>\r
246 <literallayout>$ git add git-*.sh</literallayout>\r
247 <simpara>Because this example lets shell expand the asterisk (i.e. you are\r
248 listing the files explicitly), it does not consider\r
249 <literal>subdir/git-foo.sh</literal>.</simpara>\r
250 </listitem>\r
251 </itemizedlist>\r
252 </simplesect>\r
253 <simplesect id="_interactive_mode">\r
254 <title>Interactive mode</title>\r
255 <simpara>When the command enters the interactive mode, it shows the\r
256 output of the <emphasis>status</emphasis> subcommand, and then goes into its\r
257 interactive command loop.</simpara>\r
258 <simpara>The command loop shows the list of subcommands available, and\r
259 gives a prompt "What now&gt; ".  In general, when the prompt ends\r
260 with a single <emphasis>&gt;</emphasis>, you can pick only one of the choices given\r
261 and type return, like this:</simpara>\r
262 <literallayout>    *** Commands ***\r
263       1: status       2: update       3: revert       4: add untracked\r
264       5: patch        6: diff         7: quit         8: help\r
265     What now&gt; 1</literallayout>\r
266 <simpara>You also could say "s" or "sta" or "status" above as long as the\r
267 choice is unique.</simpara>\r
268 <simpara>The main command loop has 6 subcommands (plus help and quit).</simpara>\r
269 <variablelist>\r
270 <varlistentry>\r
271 <term>\r
272 status\r
273 </term>\r
274 <listitem>\r
275 <simpara>\r
276    This shows the change between HEAD and index (i.e. what will be\r
277    committed if you say "git commit"), and between index and\r
278    working tree files (i.e. what you could stage further before\r
279    "git commit" using "git-add") for each path.  A sample output\r
280    looks like this:\r
281 </simpara>\r
282 <literallayout>              staged     unstaged path\r
283      1:       binary      nothing foo.png\r
284      2:     +403/-35        +1/-1 git-add--interactive.perl</literallayout>\r
285 <simpara>It shows that foo.png has differences from HEAD (but that is\r
286 binary so line count cannot be shown) and there is no\r
287 difference between indexed copy and the working tree\r
288 version (if the working tree version were also different,\r
289 <emphasis>binary</emphasis> would have been shown in place of <emphasis>nothing</emphasis>).  The\r
290 other file, git-add&#8212;interactive.perl, has 403 lines added\r
291 and 35 lines deleted if you commit what is in the index, but\r
292 working tree file has further modifications (one addition and\r
293 one deletion).</simpara>\r
294 </listitem>\r
295 </varlistentry>\r
296 <varlistentry>\r
297 <term>\r
298 update\r
299 </term>\r
300 <listitem>\r
301 <simpara>\r
302    This shows the status information and gives prompt\r
303    "Update&gt;&gt;".  When the prompt ends with double <emphasis>&gt;&gt;</emphasis>, you can\r
304    make more than one selection, concatenated with whitespace or\r
305    comma.  Also you can say ranges.  E.g. "2-5 7,9" to choose\r
306    2,3,4,5,7,9 from the list.  If the second number in a range is\r
307    omitted, all remaining patches are taken.  E.g. "7-" to choose\r
308    7,8,9 from the list.  You can say <emphasis>*</emphasis> to choose everything.\r
309 </simpara>\r
310 <simpara>What you chose are then highlighted with <emphasis>*</emphasis>,\r
311 like this:</simpara>\r
312 <literallayout>           staged     unstaged path\r
313   1:       binary      nothing foo.png\r
314 * 2:     +403/-35        +1/-1 git-add--interactive.perl</literallayout>\r
315 <simpara>To remove selection, prefix the input with <literal>-</literal>\r
316 like this:</simpara>\r
317 <literallayout>Update&gt;&gt; -2</literallayout>\r
318 <simpara>After making the selection, answer with an empty line to stage the\r
319 contents of working tree files for selected paths in the index.</simpara>\r
320 </listitem>\r
321 </varlistentry>\r
322 <varlistentry>\r
323 <term>\r
324 revert\r
325 </term>\r
326 <listitem>\r
327 <simpara>\r
328   This has a very similar UI to <emphasis>update</emphasis>, and the staged\r
329   information for selected paths are reverted to that of the\r
330   HEAD version.  Reverting new paths makes them untracked.\r
331 </simpara>\r
332 </listitem>\r
333 </varlistentry>\r
334 <varlistentry>\r
335 <term>\r
336 add untracked\r
337 </term>\r
338 <listitem>\r
339 <simpara>\r
340   This has a very similar UI to <emphasis>update</emphasis> and\r
341   <emphasis>revert</emphasis>, and lets you add untracked paths to the index.\r
342 </simpara>\r
343 </listitem>\r
344 </varlistentry>\r
345 <varlistentry>\r
346 <term>\r
347 patch\r
348 </term>\r
349 <listitem>\r
350 <simpara>\r
351   This lets you choose one path out of <emphasis>status</emphasis> like selection.\r
352   After choosing the path, it presents diff between the index\r
353   and the working tree file and asks you if you want to stage\r
354   the change of each hunk.  You can say:\r
355 </simpara>\r
356 <literallayout class="monospaced">y - stage this hunk\r
357 n - do not stage this hunk\r
358 a - stage this and all the remaining hunks in the file\r
359 d - do not stage this hunk nor any of the remaining hunks in the file\r
360 j - leave this hunk undecided, see next undecided hunk\r
361 J - leave this hunk undecided, see next hunk\r
362 k - leave this hunk undecided, see previous undecided hunk\r
363 K - leave this hunk undecided, see previous hunk\r
364 s - split the current hunk into smaller hunks\r
365 e - manually edit the current hunk\r
366 ? - print help</literallayout>\r
367 <simpara>After deciding the fate for all hunks, if there is any hunk\r
368 that was chosen, the index is updated with the selected hunks.</simpara>\r
369 </listitem>\r
370 </varlistentry>\r
371 <varlistentry>\r
372 <term>\r
373 diff\r
374 </term>\r
375 <listitem>\r
376 <simpara>\r
377   This lets you review what will be committed (i.e. between\r
378   HEAD and index).\r
379 </simpara>\r
380 </listitem>\r
381 </varlistentry>\r
382 </variablelist>\r
383 </simplesect>\r
384 <simplesect id="_bugs">\r
385 <title>Bugs</title>\r
386 <simpara>The interactive mode does not work with files whose names contain\r
387 characters that need C-quoting.  <literal>core.quotepath</literal> configuration can be\r
388 used to work this limitation around to some degree, but backslash,\r
389 double-quote and control characters will still have problems.</simpara>\r
390 </simplesect>\r
391 <simplesect id="_see_also">\r
392 <title>SEE ALSO</title>\r
393 <simpara><xref linkend="git-status(1)"/>\r
394 <xref linkend="git-rm(1)"/>\r
395 <xref linkend="git-reset(1)"/>\r
396 <xref linkend="git-mv(1)"/>\r
397 <xref linkend="git-commit(1)"/>\r
398 <xref linkend="git-update-index(1)"/></simpara>\r
399 </simplesect>\r
400 <simplesect id="_author">\r
401 <title>Author</title>\r
402 <simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>\r
403 </simplesect>\r
404 <simplesect id="_documentation">\r
405 <title>Documentation</title>\r
406 <simpara>Documentation by Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>\r
407 </simplesect>\r
408 <simplesect id="_git">\r
409 <title>GIT</title>\r
410 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>\r
411 </simplesect>\r
412 </article>\r