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

Re: [PATCH v5 5/5] doc: git-rebase: update discussion of internals

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 11, 2025, 21:14 UTC
Message-ID
<xmqq8qjp1ryo.fsf@gitster.g>
In-Reply-To
<5ab235b067b40e468185ee905f735ff73ccc9552.1754943127.git.gitgitgadget@gmail.com>
"Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 37 quoted lines
> From: Julia Evans <julia@jvns.ca>
>
> - make it clearer that we're talking about a multistep process
> - give a more technically accurate description how rebase works with the
>   merge backend.
> - condense the explanation of how git rebase skips commits with the same
>   textual changes into a single bullet point and remove the explanatory
>   diagram. Lots of things which are more complicated are already being
>   explained without a diagram.
> - remove the explanation of how exactly `--fork-point` and `--root`
>   work since that information is in the OPTIONS section
> - put all discussion of `ORIG_HEAD` inside the note
>
> Signed-off-by: Julia Evans <julia@jvns.ca>
> ---
>  Documentation/git-rebase.adoc | 66 ++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 43 deletions(-)
>
> diff --git a/Documentation/git-rebase.adoc b/Documentation/git-rebase.adoc
> index 750f5e67e4c3..b4e5519d2839 100644
> --- a/Documentation/git-rebase.adoc
> +++ b/Documentation/git-rebase.adoc
> @@ -68,51 +68,31 @@ linkgit:git-config[1] for details) and the `--fork-point` option is
>  assumed.  If you are currently not on any branch or if the current
>  branch does not have a configured upstream, the rebase will abort.
>  
> -All changes made by commits in the current branch but that are not
> -in `<upstream>` are saved to a temporary area.  This is the same set
> -of commits that would be shown by `git log <upstream>..HEAD`; or by
> -`git log 'fork_point'..HEAD`, if `--fork-point` is active (see the
> -description on `--fork-point` below); or by `git log HEAD`, if the
> -`--root` option is specified.
> -
> -The current branch is reset to `<upstream>` or `<newbase>` if the
> -`--onto` option was supplied.  This has the exact same effect as
> -`git reset --hard <upstream>` (or `<newbase>`). `ORIG_HEAD` is set
> -to point at the tip of the branch before the reset.
> +Here is a more detailed description of what `git rebase <upstream>` does:

Were there a sketchy description given elsewhere already? I personally feel that giving too much details here would not necessarily help readers' understanding. I'd prefer to see an introduction read more like "The command conceptually does these things in the following order", and leave the level of description also to match that introduction. It may be just me, but when somebody says "here is a detailed description", I would expect it to contain little or no white lies mixed in, even for simplicity.

But of course others may have different opinions ;-)
> +1. Make a list of all commits in the current branch that are not in
> +   `<upstream>`. This is the same set of commits that would be shown by `git log
> +   <upstream>..HEAD`. You can use `--fork-point` or `--root` to change how this
> +   list of commits is constructed.

Didn't somebody mention "git log --cherry-pick <upstream>..HEAD"? If omission of it is for simplicity, that is fine, but that is another reason why we do not want to say "more detaild description".

Also, shouldn't there be step #0 that says "If the <branch> to rebase is given, check out that branch and make it current", for the HEAD in this description to work correctly?

> +2. Check whether any of those commits are duplicates of commits already
> +   in `<upstream>`, remove them from the list, and print out a warning about
> +   each removed commit. You can use `--reapply-cherry-picks` to include
> +   duplicate commits.

This is done as part of #1 above as part of a single invocation of revision walk (i.e. a loop in sequencer.c:sequencer_make_script() that calls get_revision() repeatedly).

Show 7 quoted lines
> +3. Check out `<upstream>` (or `<newbase>` if the `--onto` option was
> +   supplied) with the equivalent of `git checkout --detach <upstream>`.
> +4. Replay the commits, one by one, in order. This is similar to running
> +   `git cherry-pick <commit>` for each commit. See REBASING MERGES for how merges
> +   are handled.
> +5. Update your branch to point to the final commit with the equivalent
> +   of `git switch -C <branch>`.

In step #3, you switched to <upstream> with "git checkout"; here you use "git switch". Uninitiated readers would wonder what criteria were used to decide which one among these two different commands to use in steps #3 and #5, even though either would work fine. Because this page is not where readers come to learn about the equivalence of these two commands that are not essential to learning "git rebase", it is better, so once you started with "git checkout", to stick to it throughout to reduce the mental burden to first-time learners.

Thanks.
Previous: Julia Evans via GitGitGadgetNext: Julia Evans via GitGitGadget
Message 60 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.