git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 4/5] doc: git-rebase: move --onto explanation down

From
Julia Evans via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 9, 2025, 01:14 UTC
Message-ID
<b37ebc8389d1c1df0f0114d9105e774d745e4361.1754702057.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1949.v4.git.1754702057.gitgitgadget@gmail.com>
From: Julia Evans <julia@jvns.ca>

There's a very clear explanation with examples of using --onto which is currently buried in the very long DESCRIPTION section. This moves it to its own section, so that we can reference the explanation from the `--onto` option by name.

Signed-off-by: Julia Evans <julia@jvns.ca>
---
 Documentation/git-rebase.adoc | 168 ++++++++++++++++++----------------
 1 file changed, 87 insertions(+), 81 deletions(-)
diff --git a/Documentation/git-rebase.adoc b/Documentation/git-rebase.adoc
index 914f743ae00f..50c84f138212 100644
--- a/Documentation/git-rebase.adoc
+++ b/Documentation/git-rebase.adoc
@@ -111,87 +111,6 @@ will result in:
     D---E---A'---F master
 ------------
 
-Here is how you would transplant a topic branch based on one
-branch to another, to pretend that you forked the topic branch
-from the latter branch, using `rebase --onto`.
-
-First let's assume your 'topic' is based on branch 'next'.
-For example, a feature developed in 'topic' depends on some
-functionality which is found in 'next'.
-
-------------
-    o---o---o---o---o  master
-         \
-          o---o---o---o---o  next
-                           \
-                            o---o---o  topic
-------------
-
-We want to make 'topic' forked from branch 'master'; for example,
-because the functionality on which 'topic' depends was merged into the
-more stable 'master' branch. We want our tree to look like this:
-
-------------
-    o---o---o---o---o  master
-        |            \
-        |             o'--o'--o'  topic
-         \
-          o---o---o---o---o  next
-------------
-
-We can get this using the following command:
-
-    git rebase --onto master next topic
-
-
-Another example of --onto option is to rebase part of a
-branch.  If we have the following situation:
-
-------------
-                            H---I---J topicB
-                           /
-                  E---F---G  topicA
-                 /
-    A---B---C---D  master
-------------
-
-then the command
-
-    git rebase --onto master topicA topicB
-
-would result in:
-
-------------
-                 H'--I'--J'  topicB
-                /
-                | E---F---G  topicA
-                |/
-    A---B---C---D  master
-------------
-
-This is useful when topicB does not depend on topicA.
-
-A range of commits could also be removed with rebase.  If we have
-the following situation:
-
-------------
-    E---F---G---H---I---J  topicA
-------------
-
-then the command
-
-    git rebase --onto topicA~5 topicA~3 topicA
-
-would result in the removal of commits F and G:
-
-------------
-    E---H'---I'---J'  topicA
-------------
-
-This is useful if F and G were flawed in some way, or should not be
-part of topicA.  Note that the argument to `--onto` and the `<upstream>`
-parameter can be any valid commit-ish.
-
 MODE OPTIONS
 ------------
 
@@ -237,6 +156,8 @@ As a special case, you may use "A\...B" as a shortcut for the
 merge base of A and B if there is exactly one merge base. You can
 leave out at most one of A and B, in which case it defaults to HEAD.
 
+See TRANSPLANTING A TOPIC BRANCH WITH --ONTO below for examples.
+
 --keep-base::
 	Set the starting point at which to create the new commits to the
 	merge base of `<upstream>` and `<branch>`. Running
@@ -1015,6 +936,91 @@ consistent (they compile, pass the testsuite, etc.) you should use
 after each commit, test, and amend the commit if fixes are necessary.
 
 
+TRANSPLANTING A TOPIC BRANCH WITH --ONTO
+----------------------------------------
+
+Here is how you would transplant a topic branch based on one
+branch to another, to pretend that you forked the topic branch
+from the latter branch, using `rebase --onto`.
+
+First let's assume your 'topic' is based on branch 'next'.
+For example, a feature developed in 'topic' depends on some
+functionality which is found in 'next'.
+
+------------
+    o---o---o---o---o  master
+         \
+          o---o---o---o---o  next
+                           \
+                            o---o---o  topic
+------------
+
+We want to make 'topic' forked from branch 'master'; for example,
+because the functionality on which 'topic' depends was merged into the
+more stable 'master' branch. We want our tree to look like this:
+
+------------
+    o---o---o---o---o  master
+        |            \
+        |             o'--o'--o'  topic
+         \
+          o---o---o---o---o  next
+------------
+
+We can get this using the following command:
+
+    git rebase --onto master next topic
+
+
+Another example of --onto option is to rebase part of a
+branch.  If we have the following situation:
+
+------------
+                            H---I---J topicB
+                           /
+                  E---F---G  topicA
+                 /
+    A---B---C---D  master
+------------
+
+then the command
+
+    git rebase --onto master topicA topicB
+
+would result in:
+
+------------
+                 H'--I'--J'  topicB
+                /
+                | E---F---G  topicA
+                |/
+    A---B---C---D  master
+------------
+
+This is useful when topicB does not depend on topicA.
+
+A range of commits could also be removed with rebase.  If we have
+the following situation:
+
+------------
+    E---F---G---H---I---J  topicA
+------------
+
+then the command
+
+    git rebase --onto topicA~5 topicA~3 topicA
+
+would result in the removal of commits F and G:
+
+------------
+    E---H'---I'---J'  topicA
+------------
+
+This is useful if F and G were flawed in some way, or should not be
+part of topicA.  Note that the argument to `--onto` and the `<upstream>`
+parameter can be any valid commit-ish.
+
+
 RECOVERING FROM UPSTREAM REBASE
 -------------------------------
 
-- 
gitgitgadget
Previous: Julia Evans via GitGitGadgetNext: D. Ben Knoble
Message 43 of 103 in “doc: git-rebase: clarify DESCRIPTION section”
  1. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 8, 2025
  2. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 8, 2025
  3. Junio C HamanoAug 8, 2025
  4. Julia EvansAug 8, 2025
  5. Junio C HamanoAug 8, 2025
  6. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 8, 2025
  7. Junio C HamanoAug 8, 2025
  8. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 8, 2025
  9. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 8, 2025
  10. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 8, 2025
  11. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 8, 2025
  12. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 8, 2025
  13. Junio C HamanoAug 8, 2025
  14. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 8, 2025
  15. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 8, 2025
  16. Junio C HamanoAug 8, 2025
  17. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 8, 2025
  18. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 8, 2025
  19. Junio C HamanoAug 8, 2025
  20. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 8, 2025
  21. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 8, 2025
  22. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 8, 2025
  23. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 8, 2025
  24. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 8, 2025
  25. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 8, 2025
  26. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 9, 2025
  27. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 9, 2025
  28. Phillip WoodAug 10, 2025
  29. Patrick SteinhardtAug 11, 2025
  30. Karthik NayakAug 11, 2025
  31. Ben KnobleAug 11, 2025
  32. Karthik NayakAug 12, 2025
  33. Junio C HamanoAug 12, 2025
  34. Phillip WoodAug 11, 2025
  35. Karthik NayakAug 12, 2025
  36. D. Ben KnobleAug 12, 2025
  37. Junio C HamanoAug 12, 2025
  38. Karthik NayakAug 14, 2025
  39. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 9, 2025
  40. Patrick SteinhardtAug 11, 2025
  41. Phillip WoodAug 11, 2025
  42. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 9, 2025
  43. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 9, 2025
  44. D. Ben KnobleAug 9, 2025
  45. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 9, 2025
  46. Phillip WoodAug 10, 2025
  47. symmetric difference with --left-only vs. range notationD. Ben Knoble, Aug 13, 2025
  48. Junio C HamanoAug 13, 2025
  49. Patrick SteinhardtAug 11, 2025
  50. Ben KnobleAug 11, 2025
  51. Patrick SteinhardtAug 11, 2025
  52. Julia EvansAug 11, 2025
  53. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 11, 2025
  54. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 11, 2025
  55. Junio C HamanoAug 11, 2025
  56. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 11, 2025
  57. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 11, 2025
  58. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 11, 2025
  59. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 11, 2025
  60. Junio C HamanoAug 11, 2025
  61. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 11, 2025
  62. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 11, 2025
  63. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 11, 2025
  64. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 11, 2025
  65. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 11, 2025
  66. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 11, 2025
  67. Junio C HamanoAug 11, 2025
  68. Julia EvansAug 11, 2025
  69. Junio C HamanoAug 11, 2025
  70. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 12, 2025
  71. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 12, 2025
  72. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 12, 2025
  73. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 12, 2025
  74. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 12, 2025
  75. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 12, 2025
  76. Junio C HamanoAug 14, 2025
  77. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 15, 2025
  78. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 15, 2025
  79. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 15, 2025
  80. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 15, 2025
  81. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 15, 2025
  82. Junio C HamanoAug 15, 2025
  83. Phillip WoodAug 18, 2025
  84. Junio C HamanoAug 18, 2025
  85. Julia EvansAug 19, 2025
  86. Junio C HamanoAug 19, 2025
  87. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 15, 2025
  88. Phillip WoodAug 18, 2025
  89. 0/5 doc: git-rebase: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Aug 23, 2025
  90. 1/5 doc: git-rebase: start with an exampleJulia Evans via GitGitGadget, Aug 23, 2025
  91. 2/5 doc: git rebase: dedup merge conflict discussionJulia Evans via GitGitGadget, Aug 23, 2025
  92. 3/5 doc: git rebase: clarify arguments syntaxJulia Evans via GitGitGadget, Aug 23, 2025
  93. 4/5 doc: git-rebase: move --onto explanation downJulia Evans via GitGitGadget, Aug 23, 2025
  94. 5/5 doc: git-rebase: update discussion of internalsJulia Evans via GitGitGadget, Aug 23, 2025
  95. Phillip WoodAug 13, 2025
  96. Julia EvansAug 13, 2025
  97. Junio C HamanoAug 14, 2025
  98. Phillip WoodAug 15, 2025
  99. Junio C HamanoAug 15, 2025
  100. Phillip WoodAug 15, 2025
  101. Julia EvansAug 15, 2025
  102. Phillip WoodAug 15, 2025
  103. D. Ben KnobleAug 9, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.