<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
<head>\r
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
-<meta name="generator" content="AsciiDoc 7.0.2" />\r
+<meta name="generator" content="AsciiDoc 8.2.5" />\r
<style type="text/css">\r
/* Debug borders */\r
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {\r
margin: 1em 5% 1em 5%;\r
}\r
\r
-a { color: blue; }\r
-a:visited { color: fuchsia; }\r
+a {\r
+ color: blue;\r
+ text-decoration: underline;\r
+}\r
+a:visited {\r
+ color: fuchsia;\r
+}\r
\r
em {\r
font-style: italic;\r
line-height: 1.3;\r
}\r
\r
-h1 {\r
+h1, h2, h3 {\r
border-bottom: 2px solid silver;\r
}\r
h2 {\r
- border-bottom: 2px solid silver;\r
padding-top: 0.5em;\r
}\r
+h3 {\r
+ float: left;\r
+}\r
+h3 + * {\r
+ clear: left;\r
+}\r
\r
div.sectionbody {\r
font-family: serif;\r
color: #527bbd;\r
font-family: sans-serif;\r
font-weight: bold;\r
- font-size: 1.2em;\r
+ font-size: 1.1em;\r
}\r
span#email {\r
}\r
padding: 0.5em;\r
}\r
\r
+div.listingblock {\r
+ margin-right: 0%;\r
+}\r
div.listingblock > div.content {\r
border: 1px solid silver;\r
background: #f4f4f4;\r
div.quoteblock > div.content {\r
padding-left: 2.0em;\r
}\r
-div.quoteblock .attribution {\r
+\r
+div.attribution {\r
text-align: right;\r
}\r
+div.verseblock + div.attribution {\r
+ text-align: left;\r
+}\r
\r
div.admonitionblock .icon {\r
vertical-align: top;\r
ul, ol {\r
list-style-position: outside;\r
}\r
-ol.olist2 {\r
+div.olist2 ol {\r
list-style-type: lower-alpha;\r
}\r
\r
div.tableblock > table {\r
- border-color: #527bbd;\r
- border-width: 3px;\r
+ border: 3px solid #527bbd;\r
}\r
thead {\r
font-family: sans-serif;\r
margin-top: 0.8em;\r
margin-bottom: 0.8em;\r
}\r
+div.hlist td {\r
+ padding-bottom: 5px;\r
+}\r
td.hlist1 {\r
vertical-align: top;\r
font-style: italic;\r
@media print {\r
div#footer-badges { display: none; }\r
}\r
-include::./stylesheets/xhtml11-manpage.css[]\r
+\r
+div#toctitle {\r
+ color: #527bbd;\r
+ font-family: sans-serif;\r
+ font-size: 1.1em;\r
+ font-weight: bold;\r
+ margin-top: 1.0em;\r
+ margin-bottom: 0.1em;\r
+}\r
+\r
+div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {\r
+ margin-top: 0;\r
+ margin-bottom: 0;\r
+}\r
+div.toclevel2 {\r
+ margin-left: 2em;\r
+ font-size: 0.9em;\r
+}\r
+div.toclevel3 {\r
+ margin-left: 4em;\r
+ font-size: 0.9em;\r
+}\r
+div.toclevel4 {\r
+ margin-left: 6em;\r
+ font-size: 0.9em;\r
+}\r
+include1::./stylesheets/xhtml11-manpage.css[]\r
/* Workarounds for IE6's broken and incomplete CSS2. */\r
\r
div.sidebar-content {\r
border-left: 2px solid silver;\r
padding-left: 0.5em;\r
}\r
+\r
+/* IE6 sets dynamically generated links as visited. */\r
+div#toc a:visited { color: blue; }\r
</style>\r
<title>git-add(1)</title>\r
</head>\r
[--update | -u] [--refresh] [--ignore-errors] [--]\r
<filepattern>…</div></div>\r
</div>\r
-<h2>DESCRIPTION</h2>\r
+<h2 id="_description">DESCRIPTION</h2>\r
<div class="sectionbody">\r
-<p>This command adds the current content of new or modified files to the\r
-index, thus staging that content for inclusion in the next commit.</p>\r
-<p>The "index" holds a snapshot of the content of the working tree, and it\r
+<div class="para"><p>This command adds the current content of new or modified files to the\r
+index, thus staging that content for inclusion in the next commit.</p></div>\r
+<div class="para"><p>The "index" holds a snapshot of the content of the working tree, and it\r
is this snapshot that is taken as the contents of the next commit. Thus\r
after making any changes to the working directory, and before running\r
the commit command, you must use the <em>add</em> command to add any new or\r
-modified files to the index.</p>\r
-<p>This command can be performed multiple times before a commit. It only\r
+modified files to the index.</p></div>\r
+<div class="para"><p>This command can be performed multiple times before a commit. It only\r
adds the content of the specified file(s) at the time the add command is\r
run; if you want subsequent changes included in the next commit, then\r
-you must run <em>git add</em> again to add the new content to the index.</p>\r
-<p>The <em>git status</em> command can be used to obtain a summary of which\r
-files have changes that are staged for the next commit.</p>\r
-<p>The <em>git add</em> command will not add ignored files by default. If any\r
+you must run <em>git add</em> again to add the new content to the index.</p></div>\r
+<div class="para"><p>The <em>git status</em> command can be used to obtain a summary of which\r
+files have changes that are staged for the next commit.</p></div>\r
+<div class="para"><p>The <em>git add</em> command will not add ignored files by default. If any\r
ignored files were explicitly specified on the command line, <em>git add</em>\r
will fail with a list of ignored files. Ignored files reached by\r
directory recursion or filename globbing performed by Git (quote your\r
globs before the shell) will be silently ignored. The <em>add</em> command can\r
-be used to add ignored files with the <tt>-f</tt> (force) option.</p>\r
-<p>Please see <a href="git-commit.html">git-commit(1)</a> for alternative ways to add content to a\r
-commit.</p>\r
+be used to add ignored files with the <tt>-f</tt> (force) option.</p></div>\r
+<div class="para"><p>Please see <a href="git-commit.html">git-commit(1)</a> for alternative ways to add content to a\r
+commit.</p></div>\r
</div>\r
-<h2>OPTIONS</h2>\r
+<h2 id="_options">OPTIONS</h2>\r
<div class="sectionbody">\r
-<dl>\r
+<div class="vlist"><dl>\r
<dt>\r
<filepattern>…\r
</dt>\r
for command-line options).\r
</p>\r
</dd>\r
-</dl>\r
+</dl></div>\r
</div>\r
-<h2>Configuration</h2>\r
+<h2 id="_configuration">Configuration</h2>\r
<div class="sectionbody">\r
-<p>The optional configuration variable <em>core.excludesfile</em> indicates a path to a\r
+<div class="para"><p>The optional configuration variable <em>core.excludesfile</em> indicates a path to a\r
file containing patterns of file names to exclude from git-add, similar to\r
$GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to\r
-those in info/exclude. See <a href="gitrepository-layout.html">gitrepository-layout(5)</a>.</p>\r
+those in info/exclude. See <a href="gitrepository-layout.html">gitrepository-layout(5)</a>.</p></div>\r
</div>\r
-<h2>EXAMPLES</h2>\r
+<h2 id="_examples">EXAMPLES</h2>\r
<div class="sectionbody">\r
-<ul>\r
+<div class="ilist"><ul>\r
<li>\r
<p>\r
Adds content from all <tt>*.txt</tt> files under <tt>Documentation</tt> directory\r
<div class="content">\r
<pre><tt>$ git add Documentation/\\*.txt</tt></pre>\r
</div></div>\r
-<p>Note that the asterisk <tt>*</tt> is quoted from the shell in this\r
+<div class="para"><p>Note that the asterisk <tt>*</tt> is quoted from the shell in this\r
example; this lets the command to include the files from\r
-subdirectories of <tt>Documentation/</tt> directory.</p>\r
+subdirectories of <tt>Documentation/</tt> directory.</p></div>\r
</li>\r
<li>\r
<p>\r
<div class="content">\r
<pre><tt>$ git add git-*.sh</tt></pre>\r
</div></div>\r
-<p>Because this example lets shell expand the asterisk (i.e. you are\r
+<div class="para"><p>Because this example lets shell expand the asterisk (i.e. you are\r
listing the files explicitly), it does not consider\r
-<tt>subdir/git-foo.sh</tt>.</p>\r
+<tt>subdir/git-foo.sh</tt>.</p></div>\r
</li>\r
-</ul>\r
+</ul></div>\r
</div>\r
-<h2>Interactive mode</h2>\r
+<h2 id="_interactive_mode">Interactive mode</h2>\r
<div class="sectionbody">\r
-<p>When the command enters the interactive mode, it shows the\r
+<div class="para"><p>When the command enters the interactive mode, it shows the\r
output of the <em>status</em> subcommand, and then goes into its\r
-interactive command loop.</p>\r
-<p>The command loop shows the list of subcommands available, and\r
+interactive command loop.</p></div>\r
+<div class="para"><p>The command loop shows the list of subcommands available, and\r
gives a prompt "What now> ". In general, when the prompt ends\r
with a single <em>></em>, you can pick only one of the choices given\r
-and type return, like this:</p>\r
+and type return, like this:</p></div>\r
<div class="listingblock">\r
<div class="content">\r
<pre><tt> *** Commands ***\r
5: patch 6: diff 7: quit 8: help\r
What now> 1</tt></pre>\r
</div></div>\r
-<p>You also could say "s" or "sta" or "status" above as long as the\r
-choice is unique.</p>\r
-<p>The main command loop has 6 subcommands (plus help and quit).</p>\r
-<dl>\r
+<div class="para"><p>You also could say "s" or "sta" or "status" above as long as the\r
+choice is unique.</p></div>\r
+<div class="para"><p>The main command loop has 6 subcommands (plus help and quit).</p></div>\r
+<div class="vlist"><dl>\r
<dt>\r
status\r
</dt>\r
1: binary nothing foo.png\r
2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>\r
</div></div>\r
-<p>It shows that foo.png has differences from HEAD (but that is\r
+<div class="para"><p>It shows that foo.png has differences from HEAD (but that is\r
binary so line count cannot be shown) and there is no\r
difference between indexed copy and the working tree\r
version (if the working tree version were also different,\r
other file, git-add--interactive.perl, has 403 lines added\r
and 35 lines deleted if you commit what is in the index, but\r
working tree file has further modifications (one addition and\r
-one deletion).</p>\r
+one deletion).</p></div>\r
</dd>\r
<dt>\r
update\r
2,3,4,5,7,9 from the list. You can say <em>*</em> to choose\r
everything.\r
</p>\r
-<p>What you chose are then highlighted with <em>*</em>,\r
-like this:</p>\r
+<div class="para"><p>What you chose are then highlighted with <em>*</em>,\r
+like this:</p></div>\r
<div class="listingblock">\r
<div class="content">\r
<pre><tt> staged unstaged path\r
1: binary nothing foo.png\r
* 2: +403/-35 +1/-1 git-add--interactive.perl</tt></pre>\r
</div></div>\r
-<p>To remove selection, prefix the input with <tt>-</tt>\r
-like this:</p>\r
+<div class="para"><p>To remove selection, prefix the input with <tt>-</tt>\r
+like this:</p></div>\r
<div class="listingblock">\r
<div class="content">\r
<pre><tt>Update>> -2</tt></pre>\r
</div></div>\r
-<p>After making the selection, answer with an empty line to stage the\r
-contents of working tree files for selected paths in the index.</p>\r
+<div class="para"><p>After making the selection, answer with an empty line to stage the\r
+contents of working tree files for selected paths in the index.</p></div>\r
</dd>\r
<dt>\r
revert\r
k - leave this hunk undecided, see previous undecided hunk\r
K - leave this hunk undecided, see previous hunk\r
s - split the current hunk into smaller hunks\r
+e - manually edit the current hunk\r
? - print help</tt></pre>\r
</div></div>\r
-<p>After deciding the fate for all hunks, if there is any hunk\r
-that was chosen, the index is updated with the selected hunks.</p>\r
+<div class="para"><p>After deciding the fate for all hunks, if there is any hunk\r
+that was chosen, the index is updated with the selected hunks.</p></div>\r
</dd>\r
<dt>\r
diff\r
HEAD and index).\r
</p>\r
</dd>\r
-</dl>\r
+</dl></div>\r
</div>\r
-<h2>Bugs</h2>\r
+<h2 id="_bugs">Bugs</h2>\r
<div class="sectionbody">\r
-<p>The interactive mode does not work with files whose names contain\r
+<div class="para"><p>The interactive mode does not work with files whose names contain\r
characters that need C-quoting. <tt>core.quotepath</tt> configuration can be\r
used to work this limitation around to some degree, but backslash,\r
-double-quote and control characters will still have problems.</p>\r
+double-quote and control characters will still have problems.</p></div>\r
</div>\r
-<h2>SEE ALSO</h2>\r
+<h2 id="_see_also">SEE ALSO</h2>\r
<div class="sectionbody">\r
-<p><a href="git-status.html">git-status(1)</a>\r
+<div class="para"><p><a href="git-status.html">git-status(1)</a>\r
<a href="git-rm.html">git-rm(1)</a>\r
<a href="git-reset.html">git-reset(1)</a>\r
<a href="git-mv.html">git-mv(1)</a>\r
<a href="git-commit.html">git-commit(1)</a>\r
-<a href="git-update-index.html">git-update-index(1)</a></p>\r
+<a href="git-update-index.html">git-update-index(1)</a></p></div>\r
</div>\r
-<h2>Author</h2>\r
+<h2 id="_author">Author</h2>\r
<div class="sectionbody">\r
-<p>Written by Linus Torvalds <torvalds@osdl.org></p>\r
+<div class="para"><p>Written by Linus Torvalds <torvalds@osdl.org></p></div>\r
</div>\r
-<h2>Documentation</h2>\r
+<h2 id="_documentation">Documentation</h2>\r
<div class="sectionbody">\r
-<p>Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.</p>\r
+<div class="para"><p>Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.</p></div>\r
</div>\r
-<h2>GIT</h2>\r
+<h2 id="_git">GIT</h2>\r
<div class="sectionbody">\r
-<p>Part of the <a href="git.html">git(1)</a> suite</p>\r
+<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 02-Jul-2008 03:01:31 UTC\r
+Last updated 2008-07-14 03:12:28 UTC\r
</div>\r
</div>\r
</body>\r
<h2>SYNOPSIS</h2>\r
<div class="sectionbody">\r
<div class="verseblock">\r
-<div class="content"><em>git stash</em> (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>] | pop [<stash>])\r
-<em>git stash</em> [save [<message>]]</div></div>\r
+<div class="content"><em>git stash</em> list\r
+<em>git stash</em> (show | apply | drop | pop ) [<stash>]\r
+<em>git stash</em> branch <branchname> [<stash>]\r
+<em>git stash</em> [save [<message>]]\r
+<em>git stash</em> clear</div></div>\r
</div>\r
<h2 id="_description">DESCRIPTION</h2>\r
<div class="sectionbody">\r
<div class="sectionbody">\r
<div class="vlist"><dl>\r
<dt>\r
-save [<message>]\r
+save [--keep-index] [<message>]\r
</dt>\r
<dd>\r
<p>\r
subcommand is given. The <message> part is optional and gives\r
the description along with the stashed state.\r
</p>\r
+<div class="para"><p>If the <tt>--keep-index</tt> option is used, all changes already added to the\r
+index are left intact.</p></div>\r
</dd>\r
<dt>\r
list [<options>]\r
longer apply the changes as they were originally).</p></div>\r
</dd>\r
<dt>\r
+branch <branchname> [<stash>]\r
+</dt>\r
+<dd>\r
+<p>\r
+ Creates and checks out a new branch named <tt><branchname></tt> starting from\r
+ the commit at which the <tt><stash></tt> was originally created, applies the\r
+ changes recorded in <tt><stash></tt> to the new working tree and index, then\r
+ drops the <tt><stash></tt> if that completes successfully. When no <tt><stash></tt>\r
+ is given, applies the latest one.\r
+</p>\r
+<div class="para"><p>This is useful if the branch on which you ran <tt>git stash save</tt> has\r
+changed enough that <tt>git stash apply</tt> fails due to conflicts. Since\r
+the stash is applied on top of the commit that was HEAD at the time\r
+<tt>git stash</tt> was run, it restores the originally stashed state with\r
+no conflicts.</p></div>\r
+</dd>\r
+<dt>\r
clear\r
</dt>\r
<dd>\r
... continue hacking ...</tt></pre>\r
</div></div>\r
</dd>\r
+<dt>\r
+Testing partial commits\r
+</dt>\r
+<dd>\r
+<p>\r
+You can use <tt>git stash save --keep-index</tt> when you want to make two or\r
+more commits out of the changes in the work tree, and you want to test\r
+each change before committing:\r
+</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>... hack hack hack ...\r
+$ git add --patch foo # add just first part to the index\r
+$ git stash save --keep-index # save all other changes to the stash\r
+$ edit/build/test first part\r
+$ git commit foo -m 'First part' # commit fully tested change\r
+$ git stash pop # prepare to work on all other changes\r
+... repeat above five steps until one commit remains ...\r
+$ edit/build/test remaining parts\r
+$ git commit foo -m 'Remaining parts'</tt></pre>\r
+</div></div>\r
+</dd>\r
</dl></div>\r
</div>\r
<h2 id="_see_also">SEE ALSO</h2>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 2008-07-06 05:17:03 UTC\r
+Last updated 2008-07-14 03:12:31 UTC\r
</div>\r
</div>\r
</body>\r
SYNOPSIS
--------
[verse]
-'git stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>] | pop [<stash>])
+'git stash' list
+'git stash' (show | apply | drop | pop ) [<stash>]
+'git stash' branch <branchname> [<stash>]
'git stash' [save [<message>]]
+'git stash' clear
DESCRIPTION
-----------
OPTIONS
-------
-save [<message>]::
+save [--keep-index] [<message>]::
Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them. This is the default action when no
subcommand is given. The <message> part is optional and gives
the description along with the stashed state.
++
+If the `--keep-index` option is used, all changes already added to the
+index are left intact.
list [<options>]::
have conflicts (which are stored in the index, where you therefore can no
longer apply the changes as they were originally).
+branch <branchname> [<stash>]::
+
+ Creates and checks out a new branch named `<branchname>` starting from
+ the commit at which the `<stash>` was originally created, applies the
+ changes recorded in `<stash>` to the new working tree and index, then
+ drops the `<stash>` if that completes successfully. When no `<stash>`
+ is given, applies the latest one.
++
+This is useful if the branch on which you ran `git stash save` has
+changed enough that `git stash apply` fails due to conflicts. Since
+the stash is applied on top of the commit that was HEAD at the time
+`git stash` was run, it restores the originally stashed state with
+no conflicts.
+
clear::
Remove all the stashed states. Note that those states will then
be subject to pruning, and may be difficult or impossible to recover.
... continue hacking ...
----------------------------------------------------------------
+Testing partial commits::
+
+You can use `git stash save --keep-index` when you want to make two or
+more commits out of the changes in the work tree, and you want to test
+each change before committing:
++
+----------------------------------------------------------------
+... hack hack hack ...
+$ git add --patch foo # add just first part to the index
+$ git stash save --keep-index # save all other changes to the stash
+$ edit/build/test first part
+$ git commit foo -m 'First part' # commit fully tested change
+$ git stash pop # prepare to work on all other changes
+... repeat above five steps until one commit remains ...
+$ edit/build/test remaining parts
+$ git commit foo -m 'Remaining parts'
+----------------------------------------------------------------
+
SEE ALSO
--------
linkgit:git-checkout[1],