Skip to content

Commit 105a65e

Browse files
committed
doc: git-rebase: update discussion of internals
- make it clearer that we're talking about a multistep process - give a more technically accurate description how rebase works with the merge backend. - delete a duplicate explanation of how git rebase skips commits with the same textual changes (it's explained in more detail a few lines further down) - 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 <[email protected]>
1 parent b37ebc8 commit 105a65e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Documentation/git-rebase.adoc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,31 @@ linkgit:git-config[1] for details) and the `--fork-point` option is
6565
assumed. If you are currently not on any branch or if the current
6666
branch does not have a configured upstream, the rebase will abort.
6767

68-
All changes made by commits in the current branch but that are not
69-
in `<upstream>` are saved to a temporary area. This is the same set
70-
of commits that would be shown by `git log <upstream>..HEAD`; or by
71-
`git log 'fork_point'..HEAD`, if `--fork-point` is active (see the
72-
description on `--fork-point` below); or by `git log HEAD`, if the
73-
`--root` option is specified.
74-
75-
The current branch is reset to `<upstream>` or `<newbase>` if the
76-
`--onto` option was supplied. This has the exact same effect as
77-
`git reset --hard <upstream>` (or `<newbase>`). `ORIG_HEAD` is set
78-
to point at the tip of the branch before the reset.
68+
Here is a more detailed description of what `git rebase <upstream>` does:
69+
70+
First, it makes a list of all commits in the current branch that are not in
71+
`<upstream>`. This is the same set of commits that would be shown by `git log
72+
<upstream>..HEAD`. You can use `--fork-point` or `--root` to change how this
73+
list of commits is constructed.
74+
75+
Then it checks out `<upstream>` (or `<newbase>` if the `--onto` option was
76+
supplied) with the equivalent of `git switch --detach <upstream>`.
77+
78+
Then it replays the commits, one by one, in order. This is similar to running
79+
`git cherry-pick <commit>` for each commit. See REBASING MERGES for how merges
80+
are handled.
81+
82+
Finally, it updates your branch to point to the final commit with the equivalent
83+
of `git switch -C <branch>`.
7984

8085
[NOTE]
86+
`ORIG_HEAD` is set to point at the tip of the branch before the rebase.
8187
`ORIG_HEAD` is not guaranteed to still point to the previous branch tip
8288
at the end of the rebase if other commands that write that pseudo-ref
8389
(e.g. `git reset`) are used during the rebase. The previous branch tip,
8490
however, is accessible using the reflog of the current branch
8591
(i.e. `@{1}`, see linkgit:gitrevisions[7]).
8692

87-
The commits that were previously saved into the temporary area are
88-
then reapplied to the current branch, one by one, in order. Note that
89-
any commits in `HEAD` which introduce the same textual changes as a commit
90-
in `HEAD..<upstream>` are omitted (i.e., a patch already accepted upstream
91-
with a different commit message or timestamp will be skipped).
92-
9393
If the upstream branch already contains a change you have made (e.g.,
9494
because you mailed a patch which was applied upstream), then that commit
9595
will be skipped and warnings will be issued (if the 'merge' backend is

0 commit comments

Comments
 (0)