Autogenerated HTML docs for v1.7.4.1-176-g501cc
[git/jnareb-git.git] / git-add.html
blob0d6173d412375566247db643a047e18dc8c660bc
1 <!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" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>git-add(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-add(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-add -
411 Add file contents to the index
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git add</em> [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
419 [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
420 [--refresh] [--ignore-errors] [--ignore-missing] [--]
421 [&lt;filepattern&gt;&#8230;]</div>
422 <div class="verseblock-attribution">
423 </div></div>
424 </div>
425 <h2 id="_description">DESCRIPTION</h2>
426 <div class="sectionbody">
427 <div class="paragraph"><p>This command updates the index using the current content found in
428 the working tree, to prepare the content staged for the next commit.
429 It typically adds the current content of existing paths as a whole,
430 but with some options it can also be used to add content with
431 only part of the changes made to the working tree files applied, or
432 remove paths that do not exist in the working tree anymore.</p></div>
433 <div class="paragraph"><p>The "index" holds a snapshot of the content of the working tree, and it
434 is this snapshot that is taken as the contents of the next commit. Thus
435 after making any changes to the working directory, and before running
436 the commit command, you must use the <tt>add</tt> command to add any new or
437 modified files to the index.</p></div>
438 <div class="paragraph"><p>This command can be performed multiple times before a commit. It only
439 adds the content of the specified file(s) at the time the add command is
440 run; if you want subsequent changes included in the next commit, then
441 you must run <tt>git add</tt> again to add the new content to the index.</p></div>
442 <div class="paragraph"><p>The <tt>git status</tt> command can be used to obtain a summary of which
443 files have changes that are staged for the next commit.</p></div>
444 <div class="paragraph"><p>The <tt>git add</tt> command will not add ignored files by default. If any
445 ignored files were explicitly specified on the command line, <tt>git add</tt>
446 will fail with a list of ignored files. Ignored files reached by
447 directory recursion or filename globbing performed by Git (quote your
448 globs before the shell) will be silently ignored. The <em>git add</em> command can
449 be used to add ignored files with the <tt>-f</tt> (force) option.</p></div>
450 <div class="paragraph"><p>Please see <a href="git-commit.html">git-commit(1)</a> for alternative ways to add content to a
451 commit.</p></div>
452 </div>
453 <h2 id="_options">OPTIONS</h2>
454 <div class="sectionbody">
455 <div class="dlist"><dl>
456 <dt class="hdlist1">
457 &lt;filepattern&gt;&#8230;
458 </dt>
459 <dd>
461 Files to add content from. Fileglobs (e.g. <tt>*.c</tt>) can
462 be given to add all matching files. Also a
463 leading directory name (e.g. <tt>dir</tt> to add <tt>dir/file1</tt>
464 and <tt>dir/file2</tt>) can be given to add all files in the
465 directory, recursively.
466 </p>
467 </dd>
468 <dt class="hdlist1">
470 </dt>
471 <dt class="hdlist1">
472 --dry-run
473 </dt>
474 <dd>
476 Don&#8217;t actually add the file(s), just show if they exist and/or will
477 be ignored.
478 </p>
479 </dd>
480 <dt class="hdlist1">
482 </dt>
483 <dt class="hdlist1">
484 --verbose
485 </dt>
486 <dd>
488 Be verbose.
489 </p>
490 </dd>
491 <dt class="hdlist1">
493 </dt>
494 <dt class="hdlist1">
495 --force
496 </dt>
497 <dd>
499 Allow adding otherwise ignored files.
500 </p>
501 </dd>
502 <dt class="hdlist1">
504 </dt>
505 <dt class="hdlist1">
506 --interactive
507 </dt>
508 <dd>
510 Add modified contents in the working tree interactively to
511 the index. Optional path arguments may be supplied to limit
512 operation to a subset of the working tree. See &#8220;Interactive
513 mode&#8221; for details.
514 </p>
515 </dd>
516 <dt class="hdlist1">
518 </dt>
519 <dt class="hdlist1">
520 --patch
521 </dt>
522 <dd>
524 Interactively choose hunks of patch between the index and the
525 work tree and add them to the index. This gives the user a chance
526 to review the difference before adding modified contents to the
527 index.
528 </p>
529 <div class="paragraph"><p>This effectively runs <tt>add --interactive</tt>, but bypasses the
530 initial command menu and directly jumps to the <tt>patch</tt> subcommand.
531 See &#8220;Interactive mode&#8221; for details.</p></div>
532 </dd>
533 <dt class="hdlist1">
534 -e, --edit
535 </dt>
536 <dd>
538 Open the diff vs. the index in an editor and let the user
539 edit it. After the editor was closed, adjust the hunk headers
540 and apply the patch to the index.
541 </p>
542 <div class="paragraph"><p>The intent of this option is to pick and choose lines of the patch to
543 apply, or even to modify the contents of lines to be staged. This can be
544 quicker and more flexible than using the interactive hunk selector.
545 However, it is easy to confuse oneself and create a patch that does not
546 apply to the index. See EDITING PATCHES below.</p></div>
547 </dd>
548 <dt class="hdlist1">
550 </dt>
551 <dt class="hdlist1">
552 --update
553 </dt>
554 <dd>
556 Only match &lt;filepattern&gt; against already tracked files in
557 the index rather than the working tree. That means that it
558 will never stage new files, but that it will stage modified
559 new contents of tracked files and that it will remove files
560 from the index if the corresponding files in the working tree
561 have been removed.
562 </p>
563 <div class="paragraph"><p>If no &lt;filepattern&gt; is given, default to "."; in other words,
564 update all tracked files in the current directory and its
565 subdirectories.</p></div>
566 </dd>
567 <dt class="hdlist1">
569 </dt>
570 <dt class="hdlist1">
571 --all
572 </dt>
573 <dd>
575 Like <tt>-u</tt>, but match &lt;filepattern&gt; against files in the
576 working tree in addition to the index. That means that it
577 will find new files as well as staging modified content and
578 removing files that are no longer in the working tree.
579 </p>
580 </dd>
581 <dt class="hdlist1">
583 </dt>
584 <dt class="hdlist1">
585 --intent-to-add
586 </dt>
587 <dd>
589 Record only the fact that the path will be added later. An entry
590 for the path is placed in the index with no content. This is
591 useful for, among other things, showing the unstaged content of
592 such files with <tt>git diff</tt> and committing them with <tt>git commit
593 -a</tt>.
594 </p>
595 </dd>
596 <dt class="hdlist1">
597 --refresh
598 </dt>
599 <dd>
601 Don&#8217;t add the file(s), but only refresh their stat()
602 information in the index.
603 </p>
604 </dd>
605 <dt class="hdlist1">
606 --ignore-errors
607 </dt>
608 <dd>
610 If some files could not be added because of errors indexing
611 them, do not abort the operation, but continue adding the
612 others. The command shall still exit with non-zero status.
613 </p>
614 </dd>
615 <dt class="hdlist1">
616 --ignore-missing
617 </dt>
618 <dd>
620 This option can only be used together with --dry-run. By using
621 this option the user can check if any of the given files would
622 be ignored, no matter if they are already present in the work
623 tree or not.
624 </p>
625 </dd>
626 <dt class="hdlist1">
628 </dt>
629 <dd>
631 This option can be used to separate command-line options from
632 the list of files, (useful when filenames might be mistaken
633 for command-line options).
634 </p>
635 </dd>
636 </dl></div>
637 </div>
638 <h2 id="_configuration">Configuration</h2>
639 <div class="sectionbody">
640 <div class="paragraph"><p>The optional configuration variable <tt>core.excludesfile</tt> indicates a path to a
641 file containing patterns of file names to exclude from git-add, similar to
642 $GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to
643 those in info/exclude. See <a href="gitrepository-layout.html">gitrepository-layout(5)</a>.</p></div>
644 </div>
645 <h2 id="_examples">EXAMPLES</h2>
646 <div class="sectionbody">
647 <div class="ulist"><ul>
648 <li>
650 Adds content from all <tt>*.txt</tt> files under <tt>Documentation</tt> directory
651 and its subdirectories:
652 </p>
653 <div class="listingblock">
654 <div class="content">
655 <pre><tt>$ git add Documentation/\*.txt</tt></pre>
656 </div></div>
657 <div class="paragraph"><p>Note that the asterisk <tt>*</tt> is quoted from the shell in this
658 example; this lets the command include the files from
659 subdirectories of <tt>Documentation/</tt> directory.</p></div>
660 </li>
661 <li>
663 Considers adding content from all git-*.sh scripts:
664 </p>
665 <div class="listingblock">
666 <div class="content">
667 <pre><tt>$ git add git-*.sh</tt></pre>
668 </div></div>
669 <div class="paragraph"><p>Because this example lets the shell expand the asterisk (i.e. you are
670 listing the files explicitly), it does not consider
671 <tt>subdir/git-foo.sh</tt>.</p></div>
672 </li>
673 </ul></div>
674 </div>
675 <h2 id="_interactive_mode">Interactive mode</h2>
676 <div class="sectionbody">
677 <div class="paragraph"><p>When the command enters the interactive mode, it shows the
678 output of the <em>status</em> subcommand, and then goes into its
679 interactive command loop.</p></div>
680 <div class="paragraph"><p>The command loop shows the list of subcommands available, and
681 gives a prompt "What now&gt; ". In general, when the prompt ends
682 with a single <em>&gt;</em>, you can pick only one of the choices given
683 and type return, like this:</p></div>
684 <div class="listingblock">
685 <div class="content">
686 <pre><tt> *** Commands ***
687 1: status 2: update 3: revert 4: add untracked
688 5: patch 6: diff 7: quit 8: help
689 What now&gt; 1</tt></pre>
690 </div></div>
691 <div class="paragraph"><p>You also could say <tt>s</tt> or <tt>sta</tt> or <tt>status</tt> above as long as the
692 choice is unique.</p></div>
693 <div class="paragraph"><p>The main command loop has 6 subcommands (plus help and quit).</p></div>
694 <div class="dlist"><dl>
695 <dt class="hdlist1">
696 status
697 </dt>
698 <dd>
700 This shows the change between HEAD and index (i.e. what will be
701 committed if you say <tt>git commit</tt>), and between index and
702 working tree files (i.e. what you could stage further before
703 <tt>git commit</tt> using <tt>git add</tt>) for each path. A sample output
704 looks like this:
705 </p>
706 <div class="listingblock">
707 <div class="content">
708 <pre><tt> staged unstaged path
709 1: binary nothing foo.png
710 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>
711 </div></div>
712 <div class="paragraph"><p>It shows that foo.png has differences from HEAD (but that is
713 binary so line count cannot be shown) and there is no
714 difference between indexed copy and the working tree
715 version (if the working tree version were also different,
716 <em>binary</em> would have been shown in place of <em>nothing</em>). The
717 other file, git-add&#45;&#45;interactive.perl, has 403 lines added
718 and 35 lines deleted if you commit what is in the index, but
719 working tree file has further modifications (one addition and
720 one deletion).</p></div>
721 </dd>
722 <dt class="hdlist1">
723 update
724 </dt>
725 <dd>
727 This shows the status information and issues an "Update&gt;&gt;"
728 prompt. When the prompt ends with double <em>&gt;&gt;</em>, you can
729 make more than one selection, concatenated with whitespace or
730 comma. Also you can say ranges. E.g. "2-5 7,9" to choose
731 2,3,4,5,7,9 from the list. If the second number in a range is
732 omitted, all remaining patches are taken. E.g. "7-" to choose
733 7,8,9 from the list. You can say <em>*</em> to choose everything.
734 </p>
735 <div class="paragraph"><p>What you chose are then highlighted with <em>*</em>,
736 like this:</p></div>
737 <div class="listingblock">
738 <div class="content">
739 <pre><tt> staged unstaged path
740 1: binary nothing foo.png
741 * 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>
742 </div></div>
743 <div class="paragraph"><p>To remove selection, prefix the input with <tt>-</tt>
744 like this:</p></div>
745 <div class="listingblock">
746 <div class="content">
747 <pre><tt>Update&gt;&gt; -2</tt></pre>
748 </div></div>
749 <div class="paragraph"><p>After making the selection, answer with an empty line to stage the
750 contents of working tree files for selected paths in the index.</p></div>
751 </dd>
752 <dt class="hdlist1">
753 revert
754 </dt>
755 <dd>
757 This has a very similar UI to <em>update</em>, and the staged
758 information for selected paths are reverted to that of the
759 HEAD version. Reverting new paths makes them untracked.
760 </p>
761 </dd>
762 <dt class="hdlist1">
763 add untracked
764 </dt>
765 <dd>
767 This has a very similar UI to <em>update</em> and
768 <em>revert</em>, and lets you add untracked paths to the index.
769 </p>
770 </dd>
771 <dt class="hdlist1">
772 patch
773 </dt>
774 <dd>
776 This lets you choose one path out of a <em>status</em> like selection.
777 After choosing the path, it presents the diff between the index
778 and the working tree file and asks you if you want to stage
779 the change of each hunk. You can say:
780 </p>
781 <div class="literalblock">
782 <div class="content">
783 <pre><tt>y - stage this hunk
784 n - do not stage this hunk
785 q - quit; do not stage this hunk nor any of the remaining ones
786 a - stage this hunk and all later hunks in the file
787 d - do not stage this hunk nor any of the later hunks in the file
788 g - select a hunk to go to
789 / - search for a hunk matching the given regex
790 j - leave this hunk undecided, see next undecided hunk
791 J - leave this hunk undecided, see next hunk
792 k - leave this hunk undecided, see previous undecided hunk
793 K - leave this hunk undecided, see previous hunk
794 s - split the current hunk into smaller hunks
795 e - manually edit the current hunk
796 ? - print help</tt></pre>
797 </div></div>
798 <div class="paragraph"><p>After deciding the fate for all hunks, if there is any hunk
799 that was chosen, the index is updated with the selected hunks.</p></div>
800 </dd>
801 <dt class="hdlist1">
802 diff
803 </dt>
804 <dd>
806 This lets you review what will be committed (i.e. between
807 HEAD and index).
808 </p>
809 </dd>
810 </dl></div>
811 </div>
812 <h2 id="_editing_patches">EDITING PATCHES</h2>
813 <div class="sectionbody">
814 <div class="paragraph"><p>Invoking <tt>git add -e</tt> or selecting <tt>e</tt> from the interactive hunk
815 selector will open a patch in your editor; after the editor exits, the
816 result is applied to the index. You are free to make arbitrary changes
817 to the patch, but note that some changes may have confusing results, or
818 even result in a patch that cannot be applied. If you want to abort the
819 operation entirely (i.e., stage nothing new in the index), simply delete
820 all lines of the patch. The list below describes some common things you
821 may see in a patch, and which editing operations make sense on them.</p></div>
822 <div class="dlist"><dl>
823 <dt class="hdlist1">
824 added content
825 </dt>
826 <dd>
828 Added content is represented by lines beginning with "&#43;". You can
829 prevent staging any addition lines by deleting them.
830 </p>
831 </dd>
832 <dt class="hdlist1">
833 removed content
834 </dt>
835 <dd>
837 Removed content is represented by lines beginning with "-". You can
838 prevent staging their removal by converting the "-" to a " " (space).
839 </p>
840 </dd>
841 <dt class="hdlist1">
842 modified content
843 </dt>
844 <dd>
846 Modified content is represented by "-" lines (removing the old content)
847 followed by "&#43;" lines (adding the replacement content). You can
848 prevent staging the modification by converting "-" lines to " ", and
849 removing "&#43;" lines. Beware that modifying only half of the pair is
850 likely to introduce confusing changes to the index.
851 </p>
852 </dd>
853 </dl></div>
854 <div class="paragraph"><p>There are also more complex operations that can be performed. But beware
855 that because the patch is applied only to the index and not the working
856 tree, the working tree will appear to "undo" the change in the index.
857 For example, introducing a new line into the index that is in neither
858 the HEAD nor the working tree will stage the new line for commit, but
859 the line will appear to be reverted in the working tree.</p></div>
860 <div class="paragraph"><p>Avoid using these constructs, or do so with extreme caution.</p></div>
861 <div class="dlist"><dl>
862 <dt class="hdlist1">
863 removing untouched content
864 </dt>
865 <dd>
867 Content which does not differ between the index and working tree may be
868 shown on context lines, beginning with a " " (space). You can stage
869 context lines for removal by converting the space to a "-". The
870 resulting working tree file will appear to re-add the content.
871 </p>
872 </dd>
873 <dt class="hdlist1">
874 modifying existing content
875 </dt>
876 <dd>
878 One can also modify context lines by staging them for removal (by
879 converting " " to "-") and adding a "&#43;" line with the new content.
880 Similarly, one can modify "&#43;" lines for existing additions or
881 modifications. In all cases, the new modification will appear reverted
882 in the working tree.
883 </p>
884 </dd>
885 <dt class="hdlist1">
886 new content
887 </dt>
888 <dd>
890 You may also add new content that does not exist in the patch; simply
891 add new lines, each starting with "&#43;". The addition will appear
892 reverted in the working tree.
893 </p>
894 </dd>
895 </dl></div>
896 <div class="paragraph"><p>There are also several operations which should be avoided entirely, as
897 they will make the patch impossible to apply:</p></div>
898 <div class="ulist"><ul>
899 <li>
901 adding context (" ") or removal ("-") lines
902 </p>
903 </li>
904 <li>
906 deleting context or removal lines
907 </p>
908 </li>
909 <li>
911 modifying the contents of context or removal lines
912 </p>
913 </li>
914 </ul></div>
915 </div>
916 <h2 id="_see_also">SEE ALSO</h2>
917 <div class="sectionbody">
918 <div class="paragraph"><p><a href="git-status.html">git-status(1)</a>
919 <a href="git-rm.html">git-rm(1)</a>
920 <a href="git-reset.html">git-reset(1)</a>
921 <a href="git-mv.html">git-mv(1)</a>
922 <a href="git-commit.html">git-commit(1)</a>
923 <a href="git-update-index.html">git-update-index(1)</a></p></div>
924 </div>
925 <h2 id="_author">Author</h2>
926 <div class="sectionbody">
927 <div class="paragraph"><p>Written by Linus Torvalds &lt;<a href="mailto:torvalds@osdl.org">torvalds@osdl.org</a>&gt;</p></div>
928 </div>
929 <h2 id="_documentation">Documentation</h2>
930 <div class="sectionbody">
931 <div class="paragraph"><p>Documentation by Junio C Hamano and the git-list &lt;<a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>&gt;.</p></div>
932 </div>
933 <h2 id="_git">GIT</h2>
934 <div class="sectionbody">
935 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
936 </div>
937 <div id="footer">
938 <div id="footer-text">
939 Last updated 2011-01-04 22:05:44 UTC
940 </div>
941 </div>
942 </body>
943 </html>