I am currently working on a project using git. Basically, my git tree consists of three branches :
- Branch A : The origin branch, from which derives my work.
- Branch B : A branch based on A. B contains development work (a new feature for A).
- Branch C : For time management reasons, I also begun the development of incomplete experimental options for the new feature. This experimental code was added directly in B. So C is the clean up branch for B, only keeping the fully operational code.
The branch relationship can be represented in this fashion :
A head-> B -> commit 0 -> ... -> commit n -> C -> clean up commit
The branch B contains all the new feature's code, sometimes mixed with optional segments still in development. All the commits in C are deletion of the experimental parts.
The code in branch C is clean and I want to forge a patch from it. The patch should include all the changes from the last commit of C to A's head.
If I do git format-patch master --stdout > my_patch.patch
, this produces a patch that will effectively end in the operational code. But this is not fine since, in the patch, the experimental code is added (through some commits in B) and then removed (clean up commits in C). In addition to not being smart at all, this also includes useless extra space (which means extra mail to share the patch with the community) and extra overhead at application.
How should I operate on these branches to produce a clean patch ? Note that I want to preserve the experimental work made so far in branch B, I just want not to include it in the patch.