Autogenerated HTML docs for v1.7.5.1-169-g505a1
[git/jnareb-git.git] / git-add.html
blob44238ce8d00626165f582a57e86a99c5bd8785ee
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 The configuration variable <tt>add.ignoreErrors</tt> can be set to
614 true to make this the default behaviour.
615 </p>
616 </dd>
617 <dt class="hdlist1">
618 --ignore-missing
619 </dt>
620 <dd>
622 This option can only be used together with --dry-run. By using
623 this option the user can check if any of the given files would
624 be ignored, no matter if they are already present in the work
625 tree or not.
626 </p>
627 </dd>
628 <dt class="hdlist1">
630 </dt>
631 <dd>
633 This option can be used to separate command-line options from
634 the list of files, (useful when filenames might be mistaken
635 for command-line options).
636 </p>
637 </dd>
638 </dl></div>
639 </div>
640 <h2 id="_configuration">Configuration</h2>
641 <div class="sectionbody">
642 <div class="paragraph"><p>The optional configuration variable <tt>core.excludesfile</tt> indicates a path to a
643 file containing patterns of file names to exclude from git-add, similar to
644 $GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to
645 those in info/exclude. See <a href="gitrepository-layout.html">gitrepository-layout(5)</a>.</p></div>
646 </div>
647 <h2 id="_examples">EXAMPLES</h2>
648 <div class="sectionbody">
649 <div class="ulist"><ul>
650 <li>
652 Adds content from all <tt>*.txt</tt> files under <tt>Documentation</tt> directory
653 and its subdirectories:
654 </p>
655 <div class="listingblock">
656 <div class="content">
657 <pre><tt>$ git add Documentation/\*.txt</tt></pre>
658 </div></div>
659 <div class="paragraph"><p>Note that the asterisk <tt>*</tt> is quoted from the shell in this
660 example; this lets the command include the files from
661 subdirectories of <tt>Documentation/</tt> directory.</p></div>
662 </li>
663 <li>
665 Considers adding content from all git-*.sh scripts:
666 </p>
667 <div class="listingblock">
668 <div class="content">
669 <pre><tt>$ git add git-*.sh</tt></pre>
670 </div></div>
671 <div class="paragraph"><p>Because this example lets the shell expand the asterisk (i.e. you are
672 listing the files explicitly), it does not consider
673 <tt>subdir/git-foo.sh</tt>.</p></div>
674 </li>
675 </ul></div>
676 </div>
677 <h2 id="_interactive_mode">Interactive mode</h2>
678 <div class="sectionbody">
679 <div class="paragraph"><p>When the command enters the interactive mode, it shows the
680 output of the <em>status</em> subcommand, and then goes into its
681 interactive command loop.</p></div>
682 <div class="paragraph"><p>The command loop shows the list of subcommands available, and
683 gives a prompt "What now&gt; ". In general, when the prompt ends
684 with a single <em>&gt;</em>, you can pick only one of the choices given
685 and type return, like this:</p></div>
686 <div class="listingblock">
687 <div class="content">
688 <pre><tt> *** Commands ***
689 1: status 2: update 3: revert 4: add untracked
690 5: patch 6: diff 7: quit 8: help
691 What now&gt; 1</tt></pre>
692 </div></div>
693 <div class="paragraph"><p>You also could say <tt>s</tt> or <tt>sta</tt> or <tt>status</tt> above as long as the
694 choice is unique.</p></div>
695 <div class="paragraph"><p>The main command loop has 6 subcommands (plus help and quit).</p></div>
696 <div class="dlist"><dl>
697 <dt class="hdlist1">
698 status
699 </dt>
700 <dd>
702 This shows the change between HEAD and index (i.e. what will be
703 committed if you say <tt>git commit</tt>), and between index and
704 working tree files (i.e. what you could stage further before
705 <tt>git commit</tt> using <tt>git add</tt>) for each path. A sample output
706 looks like this:
707 </p>
708 <div class="listingblock">
709 <div class="content">
710 <pre><tt> staged unstaged path
711 1: binary nothing foo.png
712 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>
713 </div></div>
714 <div class="paragraph"><p>It shows that foo.png has differences from HEAD (but that is
715 binary so line count cannot be shown) and there is no
716 difference between indexed copy and the working tree
717 version (if the working tree version were also different,
718 <em>binary</em> would have been shown in place of <em>nothing</em>). The
719 other file, git-add&#45;&#45;interactive.perl, has 403 lines added
720 and 35 lines deleted if you commit what is in the index, but
721 working tree file has further modifications (one addition and
722 one deletion).</p></div>
723 </dd>
724 <dt class="hdlist1">
725 update
726 </dt>
727 <dd>
729 This shows the status information and issues an "Update&gt;&gt;"
730 prompt. When the prompt ends with double <em>&gt;&gt;</em>, you can
731 make more than one selection, concatenated with whitespace or
732 comma. Also you can say ranges. E.g. "2-5 7,9" to choose
733 2,3,4,5,7,9 from the list. If the second number in a range is
734 omitted, all remaining patches are taken. E.g. "7-" to choose
735 7,8,9 from the list. You can say <em>*</em> to choose everything.
736 </p>
737 <div class="paragraph"><p>What you chose are then highlighted with <em>*</em>,
738 like this:</p></div>
739 <div class="listingblock">
740 <div class="content">
741 <pre><tt> staged unstaged path
742 1: binary nothing foo.png
743 * 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>
744 </div></div>
745 <div class="paragraph"><p>To remove selection, prefix the input with <tt>-</tt>
746 like this:</p></div>
747 <div class="listingblock">
748 <div class="content">
749 <pre><tt>Update&gt;&gt; -2</tt></pre>
750 </div></div>
751 <div class="paragraph"><p>After making the selection, answer with an empty line to stage the
752 contents of working tree files for selected paths in the index.</p></div>
753 </dd>
754 <dt class="hdlist1">
755 revert
756 </dt>
757 <dd>
759 This has a very similar UI to <em>update</em>, and the staged
760 information for selected paths are reverted to that of the
761 HEAD version. Reverting new paths makes them untracked.
762 </p>
763 </dd>
764 <dt class="hdlist1">
765 add untracked
766 </dt>
767 <dd>
769 This has a very similar UI to <em>update</em> and
770 <em>revert</em>, and lets you add untracked paths to the index.
771 </p>
772 </dd>
773 <dt class="hdlist1">
774 patch
775 </dt>
776 <dd>
778 This lets you choose one path out of a <em>status</em> like selection.
779 After choosing the path, it presents the diff between the index
780 and the working tree file and asks you if you want to stage
781 the change of each hunk. You can say:
782 </p>
783 <div class="literalblock">
784 <div class="content">
785 <pre><tt>y - stage this hunk
786 n - do not stage this hunk
787 q - quit; do not stage this hunk nor any of the remaining ones
788 a - stage this hunk and all later hunks in the file
789 d - do not stage this hunk nor any of the later hunks in the file
790 g - select a hunk to go to
791 / - search for a hunk matching the given regex
792 j - leave this hunk undecided, see next undecided hunk
793 J - leave this hunk undecided, see next hunk
794 k - leave this hunk undecided, see previous undecided hunk
795 K - leave this hunk undecided, see previous hunk
796 s - split the current hunk into smaller hunks
797 e - manually edit the current hunk
798 ? - print help</tt></pre>
799 </div></div>
800 <div class="paragraph"><p>After deciding the fate for all hunks, if there is any hunk
801 that was chosen, the index is updated with the selected hunks.</p></div>
802 </dd>
803 <dt class="hdlist1">
804 diff
805 </dt>
806 <dd>
808 This lets you review what will be committed (i.e. between
809 HEAD and index).
810 </p>
811 </dd>
812 </dl></div>
813 </div>
814 <h2 id="_editing_patches">EDITING PATCHES</h2>
815 <div class="sectionbody">
816 <div class="paragraph"><p>Invoking <tt>git add -e</tt> or selecting <tt>e</tt> from the interactive hunk
817 selector will open a patch in your editor; after the editor exits, the
818 result is applied to the index. You are free to make arbitrary changes
819 to the patch, but note that some changes may have confusing results, or
820 even result in a patch that cannot be applied. If you want to abort the
821 operation entirely (i.e., stage nothing new in the index), simply delete
822 all lines of the patch. The list below describes some common things you
823 may see in a patch, and which editing operations make sense on them.</p></div>
824 <div class="dlist"><dl>
825 <dt class="hdlist1">
826 added content
827 </dt>
828 <dd>
830 Added content is represented by lines beginning with "&#43;". You can
831 prevent staging any addition lines by deleting them.
832 </p>
833 </dd>
834 <dt class="hdlist1">
835 removed content
836 </dt>
837 <dd>
839 Removed content is represented by lines beginning with "-". You can
840 prevent staging their removal by converting the "-" to a " " (space).
841 </p>
842 </dd>
843 <dt class="hdlist1">
844 modified content
845 </dt>
846 <dd>
848 Modified content is represented by "-" lines (removing the old content)
849 followed by "&#43;" lines (adding the replacement content). You can
850 prevent staging the modification by converting "-" lines to " ", and
851 removing "&#43;" lines. Beware that modifying only half of the pair is
852 likely to introduce confusing changes to the index.
853 </p>
854 </dd>
855 </dl></div>
856 <div class="paragraph"><p>There are also more complex operations that can be performed. But beware
857 that because the patch is applied only to the index and not the working
858 tree, the working tree will appear to "undo" the change in the index.
859 For example, introducing a new line into the index that is in neither
860 the HEAD nor the working tree will stage the new line for commit, but
861 the line will appear to be reverted in the working tree.</p></div>
862 <div class="paragraph"><p>Avoid using these constructs, or do so with extreme caution.</p></div>
863 <div class="dlist"><dl>
864 <dt class="hdlist1">
865 removing untouched content
866 </dt>
867 <dd>
869 Content which does not differ between the index and working tree may be
870 shown on context lines, beginning with a " " (space). You can stage
871 context lines for removal by converting the space to a "-". The
872 resulting working tree file will appear to re-add the content.
873 </p>
874 </dd>
875 <dt class="hdlist1">
876 modifying existing content
877 </dt>
878 <dd>
880 One can also modify context lines by staging them for removal (by
881 converting " " to "-") and adding a "&#43;" line with the new content.
882 Similarly, one can modify "&#43;" lines for existing additions or
883 modifications. In all cases, the new modification will appear reverted
884 in the working tree.
885 </p>
886 </dd>
887 <dt class="hdlist1">
888 new content
889 </dt>
890 <dd>
892 You may also add new content that does not exist in the patch; simply
893 add new lines, each starting with "&#43;". The addition will appear
894 reverted in the working tree.
895 </p>
896 </dd>
897 </dl></div>
898 <div class="paragraph"><p>There are also several operations which should be avoided entirely, as
899 they will make the patch impossible to apply:</p></div>
900 <div class="ulist"><ul>
901 <li>
903 adding context (" ") or removal ("-") lines
904 </p>
905 </li>
906 <li>
908 deleting context or removal lines
909 </p>
910 </li>
911 <li>
913 modifying the contents of context or removal lines
914 </p>
915 </li>
916 </ul></div>
917 </div>
918 <h2 id="_see_also">SEE ALSO</h2>
919 <div class="sectionbody">
920 <div class="paragraph"><p><a href="git-status.html">git-status(1)</a>
921 <a href="git-rm.html">git-rm(1)</a>
922 <a href="git-reset.html">git-reset(1)</a>
923 <a href="git-mv.html">git-mv(1)</a>
924 <a href="git-commit.html">git-commit(1)</a>
925 <a href="git-update-index.html">git-update-index(1)</a></p></div>
926 </div>
927 <h2 id="_git">GIT</h2>
928 <div class="sectionbody">
929 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
930 </div>
931 <div id="footer">
932 <div id="footer-text">
933 Last updated 2011-05-05 01:29:54 UTC
934 </div>
935 </div>
936 </body>
937 </html>