Home > Enterprise >  In git, how to create a branch with commits from branch A, minus commits from B, plus commits from C
In git, how to create a branch with commits from branch A, minus commits from B, plus commits from C

Time:09-21

I have a local branch called local, that tracks origin.master but has a few commits that help with debugging and that are meant to never be pushed.

When I work on a feature, I start my feature branch from local. Then, when it is ready to be pushed, I want to get rid of my local commits, hence I want:
commits(A) - commits(B) commits(C) (from the question title)
or more precisely:
commits(feature) - commits(local) commits(origin.master).
This looks a bit like a git rebase, but not quite.

Any ideas? One might be able to find how to do this online, but I don't know what to search for, this is why I'm asking here. Thanks.

CodePudding user response:

That can be done like this:

git rebase --onto origin/master local feature

Which is saying: Take commits from feature that are not in local, place them on top of origin/master

  • Related