@matheusbsbs / matheus-bagliano / commits / 25d9f3fa2d
Fork 0

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>

J. Bruce Fields committed Apr 16, 2007 at 00:37 UTC 25d9f3fa2d493bc769e39d18bf843cf11c235062
1 file changed +8 -7
Documentation/user-manual.txt
+8 -7
@@ -504,6 +504,7 @@ $ cat .git/HEAD
504 ref: refs/heads/master
505 ------------------------------------------------
506
507 +[[detached-head]]
508 Examining an old version without creating a new branch
509 ------------------------------------------------------
510
@@ -2055,22 +2056,22 @@ $ git tag bad mywork~5
2056
2057 (Either gitk or git-log may be useful for finding the commit.)
2058
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>>):
2062
2063 -------------------------------------------------
2062 -$ git checkout -b TMP bad
2064 +$ git checkout bad
2065 $ # make changes here and update the index
2066 $ git commit --amend
2065 -$ git rebase --onto TMP bad mywork
2067 +$ git rebase --onto HEAD bad mywork
2068 -------------------------------------------------
2069
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
2072 then clean up with
2073
2074 -------------------------------------------------
2073 -$ git branch -d TMP
2075 $ git tag -d bad
2076 -------------------------------------------------
2077