I have the following situation:
(M1)---(M2)---(M3)---(M4) (master)
\
\
(A)---(B)---(C)---(D) (feature)
I branched off of master
and started developing a new feature, which I stopped at B
. I then started working on a new feature, of which I committed C
and D
. I haven't pushed anything since A
.
But, oops, I forgot to create a new branch from master
for the second feature! I now need to push the second feature, but the first one isn't finished yet. Since it's all on the same branch, I can't push, else the unfinished the first feature will go with it. So what I think I need to get to is something like this:
(A)---(B) (unfinished feature)
/
/
(M1)---(M2)---(M3)---(M4) (master)
\
\
(C)---(D) (finished feature)
From some research, I came across the following: git rebase --onto M1 C
. I don't think this is right, since I want everything after C
to be a new branch from M1
, rather than replaying C
and D
on master
. I want to keep master
and the first feature unchanged, just create a new branch for the second feature.
What is the right thing to do here, and is it even possible?
Edit: Whoops, got my structure wrong. I actually did create a branch for the second feature, but I created it off of the first feature rather than master. So it looks like:
(M1)---(M2)---(M3)---(M4) (master)
\
\
(A)---(B) (feature 1)
\
\
(C)---(D) (feature 2))
I want feature 2
to be independent of feature 1
, so not including commit A
.