Branched out from master to featureA branch. from featureA branch, branched out to featureB branch
How to rebase the featureB to master such that, all commits of featureA are avoided. Basically rebase featureB to master from the commit where featureA was branched out from?
CodePudding user response:
This sounds like a job for git rebase --onto
:
git rebase --onto master featureA featureB
In addition the the git-rebase
documentation,
this article has a good review of using the --onto
flag.
If I start with featureB
looking like this:
$ git log --oneline
244b8f1 (HEAD -> featureB) commit D
238a93a (featureA) commit C
3666cb0 commit B
c2f04ec (main) commit A
Then running:
$ git rebase --onto main featureA featureB
Results in featureB
updated to look like this:
$ git log --oneline
5608930 (HEAD -> featureB) commit D
c2f04ec (main) commit A
CodePudding user response:
git rebase master featureB
should only rebase featureB -> master while avoiding featureA completely.
To confirm changes before you do this, you can always attach the interactive flag with -i
. So the full command would look something like:
git rebase master featureB -i