diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-02-15 15:18:15 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-15 15:18:15 -0800 |
commit | e89102f576e57803186bcbec0507e49885224867 (patch) | |
tree | a7eb6c85dec2bba8a08ee969b5013ca92485a198 /git-reset.html | |
parent | a8e4261bd5f84cbc59a4a12a7908561671210aba (diff) | |
download | git-htmldocs-e89102f576e57803186bcbec0507e49885224867.tar.gz |
Autogenerated HTML docs for v2.12.0-rc1-28-gd09b6
Diffstat (limited to 'git-reset.html')
-rw-r--r-- | git-reset.html | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/git-reset.html b/git-reset.html index bd9a28db7..b9f6a155c 100644 --- a/git-reset.html +++ b/git-reset.html @@ -1220,6 +1220,74 @@ But you can use "reset --keep" to remove the unwanted commit after </li>
</ol></div>
</dd>
+<dt class="hdlist1">
+Split a commit into two
+</dt>
+<dd>
+<div class="paragraph"><p>Suppose that you have created a commit, but later decide that you want to break
+apart the changes into two logical chunks and commit each separately. You want
+to include part of the original commit into the first commit, while including
+the remainder in a second commit. You can use git reset to rewind the history
+without changing the index, and then use git add -p to interactively select
+which hunks to put into the first commit.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><code>$ git reset HEAD^ <b><1></b>
+$ git add -p <b><2></b>
+$ git diff --cached <b><3></b>
+$ git commit -c HEAD@{1} <b><4></b>
+...
+$ git add ... <b><5></b>
+$ git diff --cached <b><6></b>
+$ git commit ... <b><7></b></code></pre>
+</div></div>
+<div class="colist arabic"><ol>
+<li>
+<p>
+First, reset the history back one commit so that we remove the original
+ commit, but leave the working tree with all the changes.
+</p>
+</li>
+<li>
+<p>
+Now, interactively select hunks to add to a new commit using git add -p.
+ This will ask for each hunk separately and you can use simple commands like
+ "yes, include", "no don’t include" or even "edit".
+</p>
+</li>
+<li>
+<p>
+Once satisfied with the hunks, you should verify that it is what you
+ expected by using git diff --cached to show all changes in the index.
+</p>
+</li>
+<li>
+<p>
+Next, commit the changes stored in the index. "-c" specifies to load the
+ editor with a commit message from a previous commit so that you can re-use the
+ HEAD used to be prior to the reset command. See <a href="git-reflog.html">git-reflog(1)</a> for
+ more details.
+</p>
+</li>
+<li>
+<p>
+Now you’ve created the first commit, and can repeat steps 2-4 as often as
+ you like to break the work into any number of commits. Here we show a second
+ step which simply adds the remaining changes.
+</p>
+</li>
+<li>
+<p>
+Then check again that the changes are what you expected to add.
+</p>
+</li>
+<li>
+<p>
+And finally commit the remaining changes.
+</p>
+</li>
+</ol></div>
+</dd>
</dl></div>
</div>
</div>
@@ -1352,7 +1420,7 @@ entries:</p></div> <div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Last updated 2014-04-08 12:47:26 PDT
+Last updated 2017-02-15 15:17:51 PST
</div>
</div>
</body>
|