Skip to content

Commit 25d9f3f

Browse files
J. Bruce FieldsJunio C Hamano
authored andcommitted
user-manual: use detached head when rewriting history
This is slightly simpler if we use a detached head. And it's probably good to have another example that uses this feature. Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent a536b08 commit 25d9f3f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Documentation/user-manual.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ $ cat .git/HEAD
504504
ref: refs/heads/master
505505
------------------------------------------------
506506

507+
[[detached-head]]
507508
Examining an old version without creating a new branch
508509
------------------------------------------------------
509510

@@ -2055,22 +2056,22 @@ $ git tag bad mywork~5
20552056

20562057
(Either gitk or git-log may be useful for finding the commit.)
20572058

2058-
Then check out a new branch at that commit, edit it, and rebase the rest of
2059-
the series on top of it:
2059+
Then check out that commit, edit it, and rebase the rest of the series
2060+
on top of it (note that we could check out the commit on a temporary
2061+
branch, but instead we're using a <<detached-head,detached head>>):
20602062

20612063
-------------------------------------------------
2062-
$ git checkout -b TMP bad
2064+
$ git checkout bad
20632065
$ # make changes here and update the index
20642066
$ git commit --amend
2065-
$ git rebase --onto TMP bad mywork
2067+
$ git rebase --onto HEAD bad mywork
20662068
-------------------------------------------------
20672069

2068-
When you're done, you'll be left with mywork checked out, with the top patches
2069-
on mywork reapplied on top of the modified commit you created in TMP. You can
2070+
When you're done, you'll be left with mywork checked out, with the top
2071+
patches on mywork reapplied on top of your modified commit. You can
20702072
then clean up with
20712073

20722074
-------------------------------------------------
2073-
$ git branch -d TMP
20742075
$ git tag -d bad
20752076
-------------------------------------------------
20762077

0 commit comments

Comments
 (0)