1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
6 <meta http-equiv=
"Content-Type" content=
"application/xhtml+xml; charset=UTF-8" />
7 <meta name=
"generator" content=
"AsciiDoc 10.2.0" />
8 <title>git-add(
1)
</title>
9 <style type=
"text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.5em;
129 margin-bottom:
1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
228 div.imageblock div.content { padding-left:
0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size:
2em; }
411 span.small { font-size:
0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
443 div.tableblock
> table[
frame=
"hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock
> table[
frame=
"vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
480 border-color: #
527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-top {
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September
2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September
2006. License: GPL */
559 /* modified by Stuart Rackham,
2006,
2009. License: GPL */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([
1-'+(toclevels+
1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType ==
1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute(
"class") || i.getAttribute(
"className")) !=
"float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[
1]-
1);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
610 for (i =
0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute(
"class")
614 && entry.getAttribute(
"class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i =
0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById(
"content"), toclevels);
623 for (var i =
0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id ==
"")
626 entry.element.id =
"_toc_" + i;
627 var a = document.createElement(
"a");
628 a.href =
"#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement(
"div");
632 div.className =
"toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length ==
0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/
2005/
07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
651 var noteholder = document.getElementById(
"footnotes");
655 var entriesToRemove = [];
656 for (i =
0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute(
"class") ==
"footnote")
659 entriesToRemove.push(entry);
661 for (i =
0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById(
"content");
667 var spans = cont.getElementsByTagName(
"span");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-note");
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[
1];
679 "[<a id='_footnoteref_" + n +
"' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n +
"</a>]";
681 spans[i].setAttribute(
"data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n +
"'>" +
685 "<a href='#_footnoteref_" + n +
"' title='Return to text'>" +
686 n +
"</a>. " + note +
"</div>";
687 var id =spans[i].getAttribute(
"id");
688 if (id != null) refs[
"#"+id] = n;
692 noteholder.parentNode.removeChild(noteholder);
694 // Process footnoterefs.
695 for (i=
0; i
<spans.length; i++) {
696 if (spans[i].className ==
"footnoteref") {
697 var href = spans[i].getElementsByTagName(
"a")[
0].getAttribute(
"href");
698 href = href.match(/#.*/)[
0]; // Because IE return full URL.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-add(
1) Manual Page
741 <div class=
"sectionbody">
743 Add file contents to the index
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git add
</em> [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
753 [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse]
754 [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize]
755 [--chmod=(+|-)x] [--pathspec-from-file=
<file
> [--pathspec-file-nul]]
756 [--] [
<pathspec
>…]
</pre>
757 <div class=
"attribution">
762 <h2 id=
"_description">DESCRIPTION
</h2>
763 <div class=
"sectionbody">
764 <div class=
"paragraph"><p>This command updates the index using the current content found in
765 the working tree, to prepare the content staged for the next commit.
766 It typically adds the current content of existing paths as a whole,
767 but with some options it can also be used to add content with
768 only part of the changes made to the working tree files applied, or
769 remove paths that do not exist in the working tree anymore.
</p></div>
770 <div class=
"paragraph"><p>The
"index" holds a snapshot of the content of the working tree, and it
771 is this snapshot that is taken as the contents of the next commit. Thus
772 after making any changes to the working tree, and before running
773 the commit command, you must use the
<code>add
</code> command to add any new or
774 modified files to the index.
</p></div>
775 <div class=
"paragraph"><p>This command can be performed multiple times before a commit. It only
776 adds the content of the specified file(s) at the time the add command is
777 run; if you want subsequent changes included in the next commit, then
778 you must run
<code>git add
</code> again to add the new content to the index.
</p></div>
779 <div class=
"paragraph"><p>The
<code>git status
</code> command can be used to obtain a summary of which
780 files have changes that are staged for the next commit.
</p></div>
781 <div class=
"paragraph"><p>The
<code>git add
</code> command will not add ignored files by default. If any
782 ignored files were explicitly specified on the command line,
<code>git add
</code>
783 will fail with a list of ignored files. Ignored files reached by
784 directory recursion or filename globbing performed by Git (quote your
785 globs before the shell) will be silently ignored. The
<em>git add
</em> command can
786 be used to add ignored files with the
<code>-f
</code> (force) option.
</p></div>
787 <div class=
"paragraph"><p>Please see
<a href=
"git-commit.html">git-commit(
1)
</a> for alternative ways to add content to a
792 <h2 id=
"_options">OPTIONS
</h2>
793 <div class=
"sectionbody">
794 <div class=
"dlist"><dl>
796 <pathspec
>…
800 Files to add content from. Fileglobs (e.g.
<code>*.c
</code>) can
801 be given to add all matching files. Also a
802 leading directory name (e.g.
<code>dir
</code> to add
<code>dir/file1
</code>
803 and
<code>dir/file2
</code>) can be given to update the index to
804 match the current state of the directory as a whole (e.g.
805 specifying
<code>dir
</code> will record not just a file
<code>dir/file1
</code>
806 modified in the working tree, a file
<code>dir/file2
</code> added to
807 the working tree, but also a file
<code>dir/file3
</code> removed from
808 the working tree). Note that older versions of Git used
809 to ignore removed files; use
<code>--no-all
</code> option if you want
810 to add modified or new files but ignore removed ones.
812 <div class=
"paragraph"><p>For more details about the
<em><pathspec
></em> syntax, see the
<em>pathspec
</em> entry
813 in
<a href=
"gitglossary.html">gitglossary(
7)
</a>.
</p></div>
823 Don
’t actually add the file(s), just show if they exist and/or will
846 Allow adding otherwise ignored files.
854 Allow updating index entries outside of the sparse-checkout cone.
855 Normally,
<code>git add
</code> refuses to update index entries whose paths do
856 not fit within the sparse-checkout cone, since those files might
857 be removed from the working tree without warning. See
858 <a href=
"git-sparse-checkout.html">git-sparse-checkout(
1)
</a> for more details.
869 Add modified contents in the working tree interactively to
870 the index. Optional path arguments may be supplied to limit
871 operation to a subset of the working tree. See
“Interactive
872 mode
” for details.
883 Interactively choose hunks of patch between the index and the
884 work tree and add them to the index. This gives the user a chance
885 to review the difference before adding modified contents to the
888 <div class=
"paragraph"><p>This effectively runs
<code>add --interactive
</code>, but bypasses the
889 initial command menu and directly jumps to the
<code>patch
</code> subcommand.
890 See
“Interactive mode
” for details.
</p></div>
900 Open the diff vs. the index in an editor and let the user
901 edit it. After the editor was closed, adjust the hunk headers
902 and apply the patch to the index.
904 <div class=
"paragraph"><p>The intent of this option is to pick and choose lines of the patch to
905 apply, or even to modify the contents of lines to be staged. This can be
906 quicker and more flexible than using the interactive hunk selector.
907 However, it is easy to confuse oneself and create a patch that does not
908 apply to the index. See EDITING PATCHES below.
</p></div>
918 Update the index just where it already has an entry matching
919 <em><pathspec
></em>. This removes as well as modifies index entries to
920 match the working tree, but adds no new files.
922 <div class=
"paragraph"><p>If no
<em><pathspec
></em> is given when
<code>-u
</code> option is used, all
923 tracked files in the entire working tree are updated (old versions
924 of Git used to limit the update to the current directory and its
925 subdirectories).
</p></div>
938 Update the index not only where the working tree has a file
939 matching
<em><pathspec
></em> but also where the index already has an
940 entry. This adds, modifies, and removes index entries to
941 match the working tree.
943 <div class=
"paragraph"><p>If no
<em><pathspec
></em> is given when
<code>-A
</code> option is used, all
944 files in the entire working tree are updated (old versions
945 of Git used to limit the update to the current directory and its
946 subdirectories).
</p></div>
956 Update the index by adding new files that are unknown to the
957 index and files modified in the working tree, but ignore
958 files that have been removed from the working tree. This
959 option is a no-op when no
<em><pathspec
></em> is used.
961 <div class=
"paragraph"><p>This option is primarily to help users who are used to older
962 versions of Git, whose
"git add <em><pathspec></em>…" was a synonym
963 for
"git add --no-all <em><pathspec></em>…", i.e. ignored removed files.
</p></div>
973 Record only the fact that the path will be added later. An entry
974 for the path is placed in the index with no content. This is
975 useful for, among other things, showing the unstaged content of
976 such files with
<code>git diff
</code> and committing them with
<code>git commit
985 Don
’t add the file(s), but only refresh their stat()
986 information in the index.
994 If some files could not be added because of errors indexing
995 them, do not abort the operation, but continue adding the
996 others. The command shall still exit with non-zero status.
997 The configuration variable
<code>add.ignoreErrors
</code> can be set to
998 true to make this the default behaviour.
1001 <dt class=
"hdlist1">
1006 This option can only be used together with --dry-run. By using
1007 this option the user can check if any of the given files would
1008 be ignored, no matter if they are already present in the work
1012 <dt class=
"hdlist1">
1013 --no-warn-embedded-repo
1017 By default,
<code>git add
</code> will warn when adding an embedded
1018 repository to the index without using
<code>git submodule add
</code> to
1019 create an entry in
<code>.gitmodules
</code>. This option will suppress the
1020 warning (e.g., if you are manually performing operations on
1024 <dt class=
"hdlist1">
1029 Apply the
"clean" process freshly to all tracked files to
1030 forcibly add them again to the index. This is useful after
1031 changing
<code>core.autocrlf
</code> configuration or the
<code>text
</code> attribute
1032 in order to correct files added with wrong CRLF/LF line endings.
1033 This option implies
<code>-u
</code>. Lone CR characters are untouched, thus
1034 while a CRLF cleans to LF, a CRCRLF sequence is only partially
1038 <dt class=
"hdlist1">
1043 Override the executable bit of the added files. The executable
1044 bit is only changed in the index, the files on disk are left
1048 <dt class=
"hdlist1">
1049 --pathspec-from-file=
<file
>
1053 Pathspec is passed in
<em><file
></em> instead of commandline args. If
1054 <em><file
></em> is exactly
<code>-
</code> then standard input is used. Pathspec
1055 elements are separated by LF or CR/LF. Pathspec elements can be
1056 quoted as explained for the configuration variable
<code>core.quotePath
</code>
1057 (see
<a href=
"git-config.html">git-config(
1)
</a>). See also
<code>--pathspec-file-nul
</code> and
1058 global
<code>--literal-pathspecs
</code>.
1061 <dt class=
"hdlist1">
1066 Only meaningful with
<code>--pathspec-from-file
</code>. Pathspec elements are
1067 separated with NUL character and all other characters are taken
1068 literally (including newlines and quotes).
1071 <dt class=
"hdlist1">
1076 This option can be used to separate command-line options from
1077 the list of files, (useful when filenames might be mistaken
1078 for command-line options).
1085 <h2 id=
"_examples">EXAMPLES
</h2>
1086 <div class=
"sectionbody">
1087 <div class=
"ulist"><ul>
1090 Adds content from all
<code>*.txt
</code> files under
<code>Documentation
</code> directory
1091 and its subdirectories:
1093 <div class=
"listingblock">
1094 <div class=
"content">
1095 <pre><code>$ git add Documentation/\*.txt
</code></pre>
1097 <div class=
"paragraph"><p>Note that the asterisk
<code>*
</code> is quoted from the shell in this
1098 example; this lets the command include the files from
1099 subdirectories of
<code>Documentation/
</code> directory.
</p></div>
1103 Considers adding content from all git-*.sh scripts:
1105 <div class=
"listingblock">
1106 <div class=
"content">
1107 <pre><code>$ git add git-*.sh
</code></pre>
1109 <div class=
"paragraph"><p>Because this example lets the shell expand the asterisk (i.e. you are
1110 listing the files explicitly), it does not consider
1111 <code>subdir/git-foo.sh
</code>.
</p></div>
1117 <h2 id=
"_interactive_mode">INTERACTIVE MODE
</h2>
1118 <div class=
"sectionbody">
1119 <div class=
"paragraph"><p>When the command enters the interactive mode, it shows the
1120 output of the
<em>status
</em> subcommand, and then goes into its
1121 interactive command loop.
</p></div>
1122 <div class=
"paragraph"><p>The command loop shows the list of subcommands available, and
1123 gives a prompt
"What now> ". In general, when the prompt ends
1124 with a single
<em>></em>, you can pick only one of the choices given
1125 and type return, like this:
</p></div>
1126 <div class=
"listingblock">
1127 <div class=
"content">
1128 <pre><code> *** Commands ***
1129 1: status
2: update
3: revert
4: add untracked
1130 5: patch
6: diff
7: quit
8: help
1131 What now
> 1</code></pre>
1133 <div class=
"paragraph"><p>You also could say
<code>s
</code> or
<code>sta
</code> or
<code>status
</code> above as long as the
1134 choice is unique.
</p></div>
1135 <div class=
"paragraph"><p>The main command loop has
6 subcommands (plus help and quit).
</p></div>
1136 <div class=
"dlist"><dl>
1137 <dt class=
"hdlist1">
1142 This shows the change between HEAD and index (i.e. what will be
1143 committed if you say
<code>git commit
</code>), and between index and
1144 working tree files (i.e. what you could stage further before
1145 <code>git commit
</code> using
<code>git add
</code>) for each path. A sample output
1148 <div class=
"listingblock">
1149 <div class=
"content">
1150 <pre><code> staged unstaged path
1151 1: binary nothing foo.png
1152 2: +
403/-
35 +
1/-
1 add-interactive.c
</code></pre>
1154 <div class=
"paragraph"><p>It shows that foo.png has differences from HEAD (but that is
1155 binary so line count cannot be shown) and there is no
1156 difference between indexed copy and the working tree
1157 version (if the working tree version were also different,
1158 <em>binary
</em> would have been shown in place of
<em>nothing
</em>). The
1159 other file, add-interactive.c, has
403 lines added
1160 and
35 lines deleted if you commit what is in the index, but
1161 working tree file has further modifications (one addition and
1162 one deletion).
</p></div>
1164 <dt class=
"hdlist1">
1169 This shows the status information and issues an
"Update>>"
1170 prompt. When the prompt ends with double
<em>>></em>, you can
1171 make more than one selection, concatenated with whitespace or
1172 comma. Also you can say ranges. E.g.
"2-5 7,9" to choose
1173 2,
3,
4,
5,
7,
9 from the list. If the second number in a range is
1174 omitted, all remaining patches are taken. E.g.
"7-" to choose
1175 7,
8,
9 from the list. You can say
<em>*
</em> to choose everything.
1177 <div class=
"paragraph"><p>What you chose are then highlighted with
<em>*
</em>,
1178 like this:
</p></div>
1179 <div class=
"listingblock">
1180 <div class=
"content">
1181 <pre><code> staged unstaged path
1182 1: binary nothing foo.png
1183 *
2: +
403/-
35 +
1/-
1 add-interactive.c
</code></pre>
1185 <div class=
"paragraph"><p>To remove selection, prefix the input with
<code>-
</code>
1186 like this:
</p></div>
1187 <div class=
"listingblock">
1188 <div class=
"content">
1189 <pre><code>Update
>> -
2</code></pre>
1191 <div class=
"paragraph"><p>After making the selection, answer with an empty line to stage the
1192 contents of working tree files for selected paths in the index.
</p></div>
1194 <dt class=
"hdlist1">
1199 This has a very similar UI to
<em>update
</em>, and the staged
1200 information for selected paths are reverted to that of the
1201 HEAD version. Reverting new paths makes them untracked.
1204 <dt class=
"hdlist1">
1209 This has a very similar UI to
<em>update
</em> and
1210 <em>revert
</em>, and lets you add untracked paths to the index.
1213 <dt class=
"hdlist1">
1218 This lets you choose one path out of a
<em>status
</em> like selection.
1219 After choosing the path, it presents the diff between the index
1220 and the working tree file and asks you if you want to stage
1221 the change of each hunk. You can select one of the following
1222 options and type return:
1224 <div class=
"literalblock">
1225 <div class=
"content">
1226 <pre><code>y - stage this hunk
1227 n - do not stage this hunk
1228 q - quit; do not stage this hunk or any of the remaining ones
1229 a - stage this hunk and all later hunks in the file
1230 d - do not stage this hunk or any of the later hunks in the file
1231 g - select a hunk to go to
1232 / - search for a hunk matching the given regex
1233 j - leave this hunk undecided, see next undecided hunk
1234 J - leave this hunk undecided, see next hunk
1235 k - leave this hunk undecided, see previous undecided hunk
1236 K - leave this hunk undecided, see previous hunk
1237 s - split the current hunk into smaller hunks
1238 e - manually edit the current hunk
1239 p - print the current hunk
1240 ? - print help
</code></pre>
1242 <div class=
"paragraph"><p>After deciding the fate for all hunks, if there is any hunk
1243 that was chosen, the index is updated with the selected hunks.
</p></div>
1244 <div class=
"paragraph"><p>You can omit having to type return here, by setting the configuration
1245 variable
<code>interactive.singleKey
</code> to
<code>true
</code>.
</p></div>
1247 <dt class=
"hdlist1">
1252 This lets you review what will be committed (i.e. between
1260 <h2 id=
"_editing_patches">EDITING PATCHES
</h2>
1261 <div class=
"sectionbody">
1262 <div class=
"paragraph"><p>Invoking
<code>git add -e
</code> or selecting
<code>e
</code> from the interactive hunk
1263 selector will open a patch in your editor; after the editor exits, the
1264 result is applied to the index. You are free to make arbitrary changes
1265 to the patch, but note that some changes may have confusing results, or
1266 even result in a patch that cannot be applied. If you want to abort the
1267 operation entirely (i.e., stage nothing new in the index), simply delete
1268 all lines of the patch. The list below describes some common things you
1269 may see in a patch, and which editing operations make sense on them.
</p></div>
1270 <div class=
"openblock">
1271 <div class=
"content">
1272 <div class=
"dlist"><dl>
1273 <dt class=
"hdlist1">
1278 Added content is represented by lines beginning with
"+". You can
1279 prevent staging any addition lines by deleting them.
1282 <dt class=
"hdlist1">
1287 Removed content is represented by lines beginning with
"-". You can
1288 prevent staging their removal by converting the
"-" to a
" " (space).
1291 <dt class=
"hdlist1">
1296 Modified content is represented by
"-" lines (removing the old content)
1297 followed by
"+" lines (adding the replacement content). You can
1298 prevent staging the modification by converting
"-" lines to
" ", and
1299 removing
"+" lines. Beware that modifying only half of the pair is
1300 likely to introduce confusing changes to the index.
1305 <div class=
"paragraph"><p>There are also more complex operations that can be performed. But beware
1306 that because the patch is applied only to the index and not the working
1307 tree, the working tree will appear to
"undo" the change in the index.
1308 For example, introducing a new line into the index that is in neither
1309 the HEAD nor the working tree will stage the new line for commit, but
1310 the line will appear to be reverted in the working tree.
</p></div>
1311 <div class=
"paragraph"><p>Avoid using these constructs, or do so with extreme caution.
</p></div>
1312 <div class=
"openblock">
1313 <div class=
"content">
1314 <div class=
"dlist"><dl>
1315 <dt class=
"hdlist1">
1316 removing untouched content
1320 Content which does not differ between the index and working tree may be
1321 shown on context lines, beginning with a
" " (space). You can stage
1322 context lines for removal by converting the space to a
"-". The
1323 resulting working tree file will appear to re-add the content.
1326 <dt class=
"hdlist1">
1327 modifying existing content
1331 One can also modify context lines by staging them for removal (by
1332 converting
" " to
"-") and adding a
"+" line with the new content.
1333 Similarly, one can modify
"+" lines for existing additions or
1334 modifications. In all cases, the new modification will appear reverted
1335 in the working tree.
1338 <dt class=
"hdlist1">
1343 You may also add new content that does not exist in the patch; simply
1344 add new lines, each starting with
"+". The addition will appear
1345 reverted in the working tree.
1350 <div class=
"paragraph"><p>There are also several operations which should be avoided entirely, as
1351 they will make the patch impossible to apply:
</p></div>
1352 <div class=
"ulist"><ul>
1355 adding context (
" ") or removal (
"-") lines
1360 deleting context or removal lines
1365 modifying the contents of context or removal lines
1372 <h2 id=
"_configuration">CONFIGURATION
</h2>
1373 <div class=
"sectionbody">
1374 <div class=
"paragraph"><p>Everything below this line in this section is selectively included
1375 from the
<a href=
"git-config.html">git-config(
1)
</a> documentation. The content is the same
1376 as what
’s found there:
</p></div>
1377 <div class=
"dlist"><dl>
1378 <dt class=
"hdlist1">
1381 <dt class=
"hdlist1">
1382 add.ignore-errors (deprecated)
1386 Tells
<em>git add
</em> to continue adding files when some files cannot be
1387 added due to indexing errors. Equivalent to the
<code>--ignore-errors
</code>
1388 option of
<a href=
"git-add.html">git-add(
1)
</a>.
<code>add.ignore-errors
</code> is deprecated,
1389 as it does not follow the usual naming convention for configuration
1393 <dt class=
"hdlist1">
1394 add.interactive.useBuiltin
1398 Unused configuration variable. Used in Git versions v2.25
.0 to
1399 v2.36
.0 to enable the built-in version of
<a href=
"git-add.html">git-add(
1)
</a>'s
1400 interactive mode, which then became the default in Git
1401 versions v2.37
.0 to v2.39
.0.
1408 <h2 id=
"_see_also">SEE ALSO
</h2>
1409 <div class=
"sectionbody">
1410 <div class=
"paragraph"><p><a href=
"git-status.html">git-status(
1)
</a>
1411 <a href=
"git-rm.html">git-rm(
1)
</a>
1412 <a href=
"git-reset.html">git-reset(
1)
</a>
1413 <a href=
"git-mv.html">git-mv(
1)
</a>
1414 <a href=
"git-commit.html">git-commit(
1)
</a>
1415 <a href=
"git-update-index.html">git-update-index(
1)
</a></p></div>
1419 <h2 id=
"_git">GIT
</h2>
1420 <div class=
"sectionbody">
1421 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1425 <div id=
"footnotes"><hr /></div>
1427 <div id=
"footer-text">
1429 2024-
04-
09 14:
45:
01 PDT