Skip to content

Commit bf5f119

Browse files
committed
Merge branch 'jk/reset-to-break-a-commit-doc'
Doc update. * jk/reset-to-break-a-commit-doc: Revert "reset: add an example of how to split a commit into two"
2 parents e048a25 + ae86372 commit bf5f119

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

Documentation/git-reset.txt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -292,44 +292,6 @@ $ git reset --keep start <3>
292292
<3> But you can use "reset --keep" to remove the unwanted commit after
293293
you switched to "branch2".
294294

295-
Split a commit into two::
296-
+
297-
Suppose that you have created a commit, but later decide that you want to break
298-
apart the changes into two logical chunks and commit each separately. You want
299-
to include part of the original commit into the first commit, while including
300-
the remainder in a second commit. You can use git reset to rewind the history
301-
without changing the index, and then use git add -p to interactively select
302-
which hunks to put into the first commit.
303-
+
304-
------------
305-
$ git reset HEAD^ <1>
306-
$ git add -p <2>
307-
$ git diff --cached <3>
308-
$ git commit -c HEAD@{1} <4>
309-
...
310-
$ git add ... <5>
311-
$ git diff --cached <6>
312-
$ git commit ... <7>
313-
------------
314-
+
315-
<1> First, reset the history back one commit so that we remove the original
316-
commit, but leave the working tree with all the changes.
317-
<2> Now, interactively select hunks to add to a new commit using git add -p.
318-
This will ask for each hunk separately and you can use simple commands like
319-
"yes, include", "no don't include" or even "edit".
320-
<3> Once satisfied with the hunks, you should verify that it is what you
321-
expected by using git diff --cached to show all changes in the index.
322-
<4> Next, commit the changes stored in the index. "-c" specifies to load the
323-
editor with a commit message from a previous commit so that you can re-use the
324-
original commit message. HEAD@{1} is special notation to reference what
325-
HEAD used to be prior to the reset command. See linkgit:git-reflog[1] for
326-
more details.
327-
<5> Now you've created the first commit, and can repeat steps 2-4 as often as
328-
you like to break the work into any number of commits. Here we show a second
329-
step which simply adds the remaining changes.
330-
<6> Then check again that the changes are what you expected to add.
331-
<7> And finally commit the remaining changes.
332-
333295

334296
DISCUSSION
335297
----------

0 commit comments

Comments
 (0)