Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading