I’m looking for a solution to apply a feature branch to the development branch in git without actually moving the branch pointer. Essentially, I’d like to create a single commit off of the feature branch and make sure it’s pointing at the originating branch somehow (mention in the log might be enough).
I know that stacked git should offer something like that, although that would introduce new commands to the standard workflow which I’d rather avoid.
What I’m trying to achieve is some sort of feature management which allows us to apply / remove whole features, while keeping the visibility of the patch branch itself. If I do merge the branch, most commands trying to diff the change will not do what I want because the branch is already merged into develop.
I cannot really follow the upstream – sometimes there are concurrent changes which are easier to correct by getting new tag and reapplying only needed features, rather than resolving conflicts and reverting redundant features – so this way of work is not possible. On the other hand I do want to see the change, so that I can either rework it to match new version, or submit upstream at a later time.
To what I understand, you may use git rebase -i to achieve your goal.
Below is the scenario you want to achieve…
you can combine D-E-F as a single commit named as G
the final outcome will be
G is a single commit that have all the things in D-E-F, and you can easily take it off from the develop branch.
So in order to process this surgery, you can do….
git checkout feature_branchmake a temp branch…
git checkout -b tempgit rebase -i develop_branchand interactive editor will be prompted out…
mark commit D and E as squash, retain the last line(commit) as your last single commit
save and quit
then a commit G will rebase on to your developement branch.
Reset your development onto commit G and delete temp branch if you want.
That’s it!