Autogenerated HTML docs for v2.45.0-rc0-3-g00e10e
[git-htmldocs.git] / git-add.html
blob67dfab28369541685867a49bcd115a9e7aa0f1ea
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">
5 <head>
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 */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.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 {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
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; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
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 {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
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; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
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;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
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 {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: 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;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
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
552 * Version: 0.4
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 */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
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
586 // browsers).
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);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
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");
631 div.appendChild(a);
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.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
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");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!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];
678 spans[i].innerHTML =
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;
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
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.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-add(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-add -
743 Add file contents to the index
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
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=&lt;file&gt; [--pathspec-file-nul]]
756 [--] [&lt;pathspec&gt;&#8230;]</pre>
757 <div class="attribution">
758 </div></div>
759 </div>
760 </div>
761 <div class="sect1">
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
788 commit.</p></div>
789 </div>
790 </div>
791 <div class="sect1">
792 <h2 id="_options">OPTIONS</h2>
793 <div class="sectionbody">
794 <div class="dlist"><dl>
795 <dt class="hdlist1">
796 &lt;pathspec&gt;&#8230;
797 </dt>
798 <dd>
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.
811 </p>
812 <div class="paragraph"><p>For more details about the <em>&lt;pathspec&gt;</em> syntax, see the <em>pathspec</em> entry
813 in <a href="gitglossary.html">gitglossary(7)</a>.</p></div>
814 </dd>
815 <dt class="hdlist1">
817 </dt>
818 <dt class="hdlist1">
819 --dry-run
820 </dt>
821 <dd>
823 Don&#8217;t actually add the file(s), just show if they exist and/or will
824 be ignored.
825 </p>
826 </dd>
827 <dt class="hdlist1">
829 </dt>
830 <dt class="hdlist1">
831 --verbose
832 </dt>
833 <dd>
835 Be verbose.
836 </p>
837 </dd>
838 <dt class="hdlist1">
840 </dt>
841 <dt class="hdlist1">
842 --force
843 </dt>
844 <dd>
846 Allow adding otherwise ignored files.
847 </p>
848 </dd>
849 <dt class="hdlist1">
850 --sparse
851 </dt>
852 <dd>
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.
859 </p>
860 </dd>
861 <dt class="hdlist1">
863 </dt>
864 <dt class="hdlist1">
865 --interactive
866 </dt>
867 <dd>
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 &#8220;Interactive
872 mode&#8221; for details.
873 </p>
874 </dd>
875 <dt class="hdlist1">
877 </dt>
878 <dt class="hdlist1">
879 --patch
880 </dt>
881 <dd>
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
886 index.
887 </p>
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 &#8220;Interactive mode&#8221; for details.</p></div>
891 </dd>
892 <dt class="hdlist1">
894 </dt>
895 <dt class="hdlist1">
896 --edit
897 </dt>
898 <dd>
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.
903 </p>
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>
909 </dd>
910 <dt class="hdlist1">
912 </dt>
913 <dt class="hdlist1">
914 --update
915 </dt>
916 <dd>
918 Update the index just where it already has an entry matching
919 <em>&lt;pathspec&gt;</em>. This removes as well as modifies index entries to
920 match the working tree, but adds no new files.
921 </p>
922 <div class="paragraph"><p>If no <em>&lt;pathspec&gt;</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>
926 </dd>
927 <dt class="hdlist1">
929 </dt>
930 <dt class="hdlist1">
931 --all
932 </dt>
933 <dt class="hdlist1">
934 --no-ignore-removal
935 </dt>
936 <dd>
938 Update the index not only where the working tree has a file
939 matching <em>&lt;pathspec&gt;</em> but also where the index already has an
940 entry. This adds, modifies, and removes index entries to
941 match the working tree.
942 </p>
943 <div class="paragraph"><p>If no <em>&lt;pathspec&gt;</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>
947 </dd>
948 <dt class="hdlist1">
949 --no-all
950 </dt>
951 <dt class="hdlist1">
952 --ignore-removal
953 </dt>
954 <dd>
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>&lt;pathspec&gt;</em> is used.
960 </p>
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>&lt;pathspec&gt;</em>&#8230;" was a synonym
963 for "git add --no-all <em>&lt;pathspec&gt;</em>&#8230;", i.e. ignored removed files.</p></div>
964 </dd>
965 <dt class="hdlist1">
967 </dt>
968 <dt class="hdlist1">
969 --intent-to-add
970 </dt>
971 <dd>
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
977 -a</code>.
978 </p>
979 </dd>
980 <dt class="hdlist1">
981 --refresh
982 </dt>
983 <dd>
985 Don&#8217;t add the file(s), but only refresh their stat()
986 information in the index.
987 </p>
988 </dd>
989 <dt class="hdlist1">
990 --ignore-errors
991 </dt>
992 <dd>
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.
999 </p>
1000 </dd>
1001 <dt class="hdlist1">
1002 --ignore-missing
1003 </dt>
1004 <dd>
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
1009 tree or not.
1010 </p>
1011 </dd>
1012 <dt class="hdlist1">
1013 --no-warn-embedded-repo
1014 </dt>
1015 <dd>
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
1021 submodules).
1022 </p>
1023 </dd>
1024 <dt class="hdlist1">
1025 --renormalize
1026 </dt>
1027 <dd>
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
1035 cleaned to CRLF.
1036 </p>
1037 </dd>
1038 <dt class="hdlist1">
1039 --chmod=(+|-)x
1040 </dt>
1041 <dd>
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
1045 unchanged.
1046 </p>
1047 </dd>
1048 <dt class="hdlist1">
1049 --pathspec-from-file=&lt;file&gt;
1050 </dt>
1051 <dd>
1053 Pathspec is passed in <em>&lt;file&gt;</em> instead of commandline args. If
1054 <em>&lt;file&gt;</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>.
1059 </p>
1060 </dd>
1061 <dt class="hdlist1">
1062 --pathspec-file-nul
1063 </dt>
1064 <dd>
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).
1069 </p>
1070 </dd>
1071 <dt class="hdlist1">
1073 </dt>
1074 <dd>
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).
1079 </p>
1080 </dd>
1081 </dl></div>
1082 </div>
1083 </div>
1084 <div class="sect1">
1085 <h2 id="_examples">EXAMPLES</h2>
1086 <div class="sectionbody">
1087 <div class="ulist"><ul>
1088 <li>
1090 Adds content from all <code>*.txt</code> files under <code>Documentation</code> directory
1091 and its subdirectories:
1092 </p>
1093 <div class="listingblock">
1094 <div class="content">
1095 <pre><code>$ git add Documentation/\*.txt</code></pre>
1096 </div></div>
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>
1100 </li>
1101 <li>
1103 Considers adding content from all git-*.sh scripts:
1104 </p>
1105 <div class="listingblock">
1106 <div class="content">
1107 <pre><code>$ git add git-*.sh</code></pre>
1108 </div></div>
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>
1112 </li>
1113 </ul></div>
1114 </div>
1115 </div>
1116 <div class="sect1">
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&gt; ". In general, when the prompt ends
1124 with a single <em>&gt;</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&gt; 1</code></pre>
1132 </div></div>
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">
1138 status
1139 </dt>
1140 <dd>
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
1146 looks like this:
1147 </p>
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>
1153 </div></div>
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>
1163 </dd>
1164 <dt class="hdlist1">
1165 update
1166 </dt>
1167 <dd>
1169 This shows the status information and issues an "Update&gt;&gt;"
1170 prompt. When the prompt ends with double <em>&gt;&gt;</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.
1176 </p>
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>
1184 </div></div>
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&gt;&gt; -2</code></pre>
1190 </div></div>
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>
1193 </dd>
1194 <dt class="hdlist1">
1195 revert
1196 </dt>
1197 <dd>
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.
1202 </p>
1203 </dd>
1204 <dt class="hdlist1">
1205 add untracked
1206 </dt>
1207 <dd>
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.
1211 </p>
1212 </dd>
1213 <dt class="hdlist1">
1214 patch
1215 </dt>
1216 <dd>
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:
1223 </p>
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>
1241 </div></div>
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>
1246 </dd>
1247 <dt class="hdlist1">
1248 diff
1249 </dt>
1250 <dd>
1252 This lets you review what will be committed (i.e. between
1253 HEAD and index).
1254 </p>
1255 </dd>
1256 </dl></div>
1257 </div>
1258 </div>
1259 <div class="sect1">
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">
1274 added content
1275 </dt>
1276 <dd>
1278 Added content is represented by lines beginning with "&#43;". You can
1279 prevent staging any addition lines by deleting them.
1280 </p>
1281 </dd>
1282 <dt class="hdlist1">
1283 removed content
1284 </dt>
1285 <dd>
1287 Removed content is represented by lines beginning with "-". You can
1288 prevent staging their removal by converting the "-" to a " " (space).
1289 </p>
1290 </dd>
1291 <dt class="hdlist1">
1292 modified content
1293 </dt>
1294 <dd>
1296 Modified content is represented by "-" lines (removing the old content)
1297 followed by "&#43;" lines (adding the replacement content). You can
1298 prevent staging the modification by converting "-" lines to " ", and
1299 removing "&#43;" lines. Beware that modifying only half of the pair is
1300 likely to introduce confusing changes to the index.
1301 </p>
1302 </dd>
1303 </dl></div>
1304 </div></div>
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
1317 </dt>
1318 <dd>
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.
1324 </p>
1325 </dd>
1326 <dt class="hdlist1">
1327 modifying existing content
1328 </dt>
1329 <dd>
1331 One can also modify context lines by staging them for removal (by
1332 converting " " to "-") and adding a "&#43;" line with the new content.
1333 Similarly, one can modify "&#43;" lines for existing additions or
1334 modifications. In all cases, the new modification will appear reverted
1335 in the working tree.
1336 </p>
1337 </dd>
1338 <dt class="hdlist1">
1339 new content
1340 </dt>
1341 <dd>
1343 You may also add new content that does not exist in the patch; simply
1344 add new lines, each starting with "&#43;". The addition will appear
1345 reverted in the working tree.
1346 </p>
1347 </dd>
1348 </dl></div>
1349 </div></div>
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>
1353 <li>
1355 adding context (" ") or removal ("-") lines
1356 </p>
1357 </li>
1358 <li>
1360 deleting context or removal lines
1361 </p>
1362 </li>
1363 <li>
1365 modifying the contents of context or removal lines
1366 </p>
1367 </li>
1368 </ul></div>
1369 </div>
1370 </div>
1371 <div class="sect1">
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&#8217;s found there:</p></div>
1377 <div class="dlist"><dl>
1378 <dt class="hdlist1">
1379 add.ignoreErrors
1380 </dt>
1381 <dt class="hdlist1">
1382 add.ignore-errors (deprecated)
1383 </dt>
1384 <dd>
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
1390 variables.
1391 </p>
1392 </dd>
1393 <dt class="hdlist1">
1394 add.interactive.useBuiltin
1395 </dt>
1396 <dd>
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.
1402 </p>
1403 </dd>
1404 </dl></div>
1405 </div>
1406 </div>
1407 <div class="sect1">
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>
1416 </div>
1417 </div>
1418 <div class="sect1">
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>
1422 </div>
1423 </div>
1424 </div>
1425 <div id="footnotes"><hr /></div>
1426 <div id="footer">
1427 <div id="footer-text">
1428 Last updated
1429 2024-04-09 14:45:01 PDT
1430 </div>
1431 </div>
1432 </body>
1433 </html>