blob: 4e175ed5b2812b63d30004bf621f7d61cb37766f [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano7e9f6b72006-02-22 10:44:556<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-add(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-add(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-add -
Junio C Hamanoe7935c42006-12-13 21:32:17269 Add file contents to the changeset to be committed next
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano3d30fd52007-05-08 00:32:53275<p><em>git-add</em> [-n] [-v] [-f] [--interactive | -i] [-u] [--] &lt;file&gt;&#8230;</p>
Junio C Hamano1a4e8412005-12-27 08:17:23276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
Junio C Hamanoe7935c42006-12-13 21:32:17279<p>All the changed file contents to be committed together in a single set
280of changes must be "added" with the <em>add</em> command before using the
281<em>commit</em> command. This is not only for adding new files. Even modified
282files must be added to the set of changes about to be committed.</p>
283<p>This command can be performed multiple times before a commit. The added
284content corresponds to the state of specified file(s) at the time the
285<em>add</em> command is used. This means the <em>commit</em> command will not consider
286subsequent changes to already added content if it is not added again before
287the commit.</p>
288<p>The <em>git status</em> command can be used to obtain a summary of what is included
289for the next commit.</p>
Junio C Hamano3d2adc72006-12-26 03:21:45290<p>This command can be used to add ignored files with <tt>-f</tt> (force)
291option, but they have to be
292explicitly and exactly specified from the command line. File globbing
293and recursive behaviour do not add ignored files.</p>
Junio C Hamanoe7935c42006-12-13 21:32:17294<p>Please see <a href="git-commit.html">git-commit(1)</a> for alternative ways to add content to a
295commit.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23296</div>
297<h2>OPTIONS</h2>
298<div class="sectionbody">
299<dl>
300<dt>
301&lt;file&gt;&#8230;
302</dt>
303<dd>
304<p>
Junio C Hamano3d2adc72006-12-26 03:21:45305 Files to add content from. Fileglobs (e.g. <tt>*.c</tt>) can
306 be given to add all matching files. Also a
307 leading directory name (e.g. <tt>dir</tt> to add <tt>dir/file1</tt>
308 and <tt>dir/file2</tt>) can be given to add all files in the
309 directory, recursively.
Junio C Hamano1a4e8412005-12-27 08:17:23310</p>
311</dd>
312<dt>
313-n
314</dt>
315<dd>
316<p>
317 Don't actually add the file(s), just show if they exist.
318</p>
319</dd>
320<dt>
321-v
322</dt>
323<dd>
324<p>
325 Be verbose.
326</p>
327</dd>
Junio C Hamano7e9f6b72006-02-22 10:44:55328<dt>
Junio C Hamano3d2adc72006-12-26 03:21:45329-f
330</dt>
331<dd>
332<p>
333 Allow adding otherwise ignored files.
334</p>
335</dd>
336<dt>
Junio C Hamanoa3fd83c2007-03-02 10:34:36337-i, --interactive
Junio C Hamano17bbaca2006-12-25 11:36:31338</dt>
339<dd>
340<p>
341 Add modified contents in the working tree interactively to
342 the index.
343</p>
344</dd>
345<dt>
Junio C Hamano3d30fd52007-05-08 00:32:53346-u
347</dt>
348<dd>
349<p>
Junio C Hamano0430e3a2007-05-15 03:13:17350 Update only files that git already knows about. This is similar
351 to what "git commit -a" does in preparation for making a commit,
352 except that the update is limited to paths specified on the
353 command line. If no paths are specified, all tracked files are
354 updated.
Junio C Hamano3d30fd52007-05-08 00:32:53355</p>
356</dd>
357<dt>
Junio C Hamano1bb569e2006-05-05 23:14:25358--
Junio C Hamano7e9f6b72006-02-22 10:44:55359</dt>
360<dd>
361<p>
362 This option can be used to separate command-line options from
363 the list of files, (useful when filenames might be mistaken
364 for command-line options).
365</p>
366</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23367</dl>
368</div>
Junio C Hamano9fbd4f72007-05-18 15:54:37369<h2>Configuration</h2>
370<div class="sectionbody">
371<p>The optional configuration variable <em>core.excludesfile</em> indicates a path to a
372file containing patterns of file names to exclude from git-add, similar to
373$GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to
374those in info/exclude. See <a href="repository-layout.html">repository layout</a>.</p>
375</div>
Junio C Hamano1a4e8412005-12-27 08:17:23376<h2>EXAMPLES</h2>
377<div class="sectionbody">
378<dl>
379<dt>
380git-add Documentation/\*.txt
381</dt>
382<dd>
383<p>
Junio C Hamanoe7935c42006-12-13 21:32:17384 Adds content from all <tt>*.txt</tt> files under <tt>Documentation</tt>
385 directory and its subdirectories.
Junio C Hamano1a4e8412005-12-27 08:17:23386</p>
387<p>Note that the asterisk <tt>*</tt> is quoted from the shell in this
388example; this lets the command to include the files from
389subdirectories of <tt>Documentation/</tt> directory.</p>
390</dd>
391<dt>
392git-add git-*.sh
393</dt>
394<dd>
395<p>
Junio C Hamanoe7935c42006-12-13 21:32:17396 Considers adding content from all git-*.sh scripts.
Junio C Hamano1a4e8412005-12-27 08:17:23397 Because this example lets shell expand the asterisk
398 (i.e. you are listing the files explicitly), it does not
Junio C Hamanoe7935c42006-12-13 21:32:17399 consider <tt>subdir/git-foo.sh</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23400</p>
401</dd>
402</dl>
403</div>
Junio C Hamano17bbaca2006-12-25 11:36:31404<h2>Interactive mode</h2>
405<div class="sectionbody">
406<p>When the command enters the interactive mode, it shows the
Junio C Hamanof9771f62007-01-17 17:42:30407output of the <em>status</em> subcommand, and then goes into its
Junio C Hamano17bbaca2006-12-25 11:36:31408interactive command loop.</p>
409<p>The command loop shows the list of subcommands available, and
410gives a prompt "What now&gt; ". In general, when the prompt ends
411with a single <em>&gt;</em>, you can pick only one of the choices given
412and type return, like this:</p>
413<div class="listingblock">
414<div class="content">
415<pre><tt> *** Commands ***
416 1: status 2: update 3: revert 4: add untracked
417 5: patch 6: diff 7: quit 8: help
418 What now&gt; 1</tt></pre>
419</div></div>
420<p>You also could say "s" or "sta" or "status" above as long as the
421choice is unique.</p>
422<p>The main command loop has 6 subcommands (plus help and quit).</p>
423<dl>
424<dt>
425status
426</dt>
427<dd>
428<p>
429 This shows the change between HEAD and index (i.e. what will be
430 committed if you say "git commit"), and between index and
431 working tree files (i.e. what you could stage further before
432 "git commit" using "git-add") for each path. A sample output
433 looks like this:
434</p>
435<div class="listingblock">
436<div class="content">
437<pre><tt> staged unstaged path
438 1: binary nothing foo.png
439 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>
440</div></div>
441<p>It shows that foo.png has differences from HEAD (but that is
442binary so line count cannot be shown) and there is no
443difference between indexed copy and the working tree
444version (if the working tree version were also different,
445<em>binary</em> would have been shown in place of <em>nothing</em>). The
446other file, git-add--interactive.perl, has 403 lines added
447and 35 lines deleted if you commit what is in the index, but
448working tree file has further modifications (one addition and
449one deletion).</p>
450</dd>
451<dt>
452update
453</dt>
454<dd>
455<p>
456 This shows the status information and gives prompt
457 "Update&gt;&gt;". When the prompt ends with double <em>&gt;&gt;</em>, you can
458 make more than one selection, concatenated with whitespace or
459 comma. Also you can say ranges. E.g. "2-5 7,9" to choose
460 2,3,4,5,7,9 from the list. You can say <em>*</em> to choose
461 everything.
462</p>
463<p>What you chose are then highlighted with <em>*</em>,
464like this:</p>
465<div class="listingblock">
466<div class="content">
467<pre><tt> staged unstaged path
468 1: binary nothing foo.png
469* 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>
470</div></div>
471<p>To remove selection, prefix the input with <tt>-</tt>
472like this:</p>
473<div class="listingblock">
474<div class="content">
475<pre><tt>Update&gt;&gt; -2</tt></pre>
476</div></div>
477<p>After making the selection, answer with an empty line to stage the
478contents of working tree files for selected paths in the index.</p>
479</dd>
480<dt>
481revert
482</dt>
483<dd>
484<p>
485 This has a very similar UI to <em>update</em>, and the staged
486 information for selected paths are reverted to that of the
487 HEAD version. Reverting new paths makes them untracked.
488</p>
489</dd>
490<dt>
491add untracked
492</dt>
493<dd>
494<p>
495 This has a very similar UI to <em>update</em> and
496 <em>revert</em>, and lets you add untracked paths to the index.
497</p>
498</dd>
499<dt>
500patch
501</dt>
502<dd>
503<p>
504 This lets you choose one path out of <em>status</em> like selection.
505 After choosing the path, it presents diff between the index
506 and the working tree file and asks you if you want to stage
507 the change of each hunk. You can say:
508</p>
509<div class="literalblock">
510<div class="content">
511<pre><tt>y - add the change from that hunk to index
512n - do not add the change from that hunk to index
513a - add the change from that hunk and all the rest to index
514d - do not the change from that hunk nor any of the rest to index
515j - do not decide on this hunk now, and view the next
516 undecided hunk
517J - do not decide on this hunk now, and view the next hunk
518k - do not decide on this hunk now, and view the previous
519 undecided hunk
520K - do not decide on this hunk now, and view the previous hunk</tt></pre>
521</div></div>
522<p>After deciding the fate for all hunks, if there is any hunk
523that was chosen, the index is updated with the selected hunks.</p>
524</dd>
525<dt>
526diff
527</dt>
528<dd>
529<p>
530 This lets you review what will be committed (i.e. between
531 HEAD and index).
532</p>
533</dd>
534</dl>
535</div>
Junio C Hamano2bb13102006-03-06 07:10:21536<h2>See Also</h2>
537<div class="sectionbody">
Junio C Hamanoe7935c42006-12-13 21:32:17538<p><a href="git-status.html">git-status(1)</a>
539<a href="git-rm.html">git-rm(1)</a>
540<a href="git-mv.html">git-mv(1)</a>
541<a href="git-commit.html">git-commit(1)</a>
542<a href="git-update-index.html">git-update-index(1)</a></p>
Junio C Hamano2bb13102006-03-06 07:10:21543</div>
Junio C Hamano1a4e8412005-12-27 08:17:23544<h2>Author</h2>
545<div class="sectionbody">
546<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
547</div>
548<h2>Documentation</h2>
549<div class="sectionbody">
550<p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
551</div>
552<h2>GIT</h2>
553<div class="sectionbody">
554<p>Part of the <a href="git.html">git(7)</a> suite</p>
555</div>
556<div id="footer">
557<div id="footer-text">
Junio C Hamanobb6e0782007-07-19 02:14:50558Last updated 19-Jul-2007 02:09:30 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23559</div>
560</div>
561</body>
562</html>