Referencing this excellent answer, which I read and (I think) I understood, but as far as I see does not answer my specific question (because it explains how to rebase onto a commit in a different branch, but I want to rebase on the same branch).
Situation
- There are two branches,
master
andfeature
,feature
at some point gets rebased on top ofmaster
- Later, for whatever reason* we want
feature
to "branch out" from one of the previous commits ofmaster
(* EDIT: reason, e.g.: changes in the local feature
branch broke, after rebasing it on to master
, so try to find out, which commit on master
broke the feature
branch, in a similar way as git-bisect
)
Question: How to achieve this?
Illustration
How to go from this:
G--H--I--J <-- feature
/
A--B--C--D--E--F <-- master
...to this?
G--H--I--J <-- feature
/
A--B--C--D--E--F <-- master
Attempts so far
Attempt #1:
git checkout feature
git rebase C
Result: Current branch bug/8985-miniredis is up to date.
Nothing changed.
I think this result is quite logical, because for git, C
is also part of the "current branch". (Although, from my point of view, the "current branch" is only G..J
)
Attempt #2:
git checkout feature
git rebase --onto C feature
Result: First, rewinding head to replay your work on top of it...
. And then feature
simply points to C
and the other commits are "lost". I don't really understand what is going on here, but again, git cannot know that feature
"starts" at F
, from my point of view.
Attempt #3:
git checkout feature
git rebase --onto C master..feature
Result: fatal: invalid upstream 'master..feature'
As stated in the comments of that answer, this is not possible, because git
inserts the ..HEAD
part itself. But surely, there must be some way to achieve this?
Question in other words:
How to achieve what git rebase --onto C master..feature
would do if it was valid?