I'm using git-flow to maintain my branches, hence I have a master and develop branches.
Develop is several commits (~50-100) ahead of master.
However, there is a need to bring selective features from develop to master ahead of schedule.
How can I do this? Should be using cherry-pick? What happens if I rebase develop on master again later before the final merge back to master?
First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch.
Not committing to master prevents colliding commits and having to merge each time 2 people change the same file.
Under Branches, double-click the feature branch that is behind to switch to that branch. Click the Merge button. From the popup that appears, select the commit you want to merge into your feature branch. Check the Create a commit even if merge resolved via fast-forward option at the bottom.
Have you considered creating another develop branch just for integrating these particular features, then using either rebase -i
to remove commits you don't want, or cherry-pick the commits you do want into that branch?
It seems that you might even be able to use a git flow release branch to do this, though if you do you'd have to go with the interactive rebase/removal approach. It's not the way release is intended, but it at least keeps master clean.
The process of removing changes at release time is documented pretty well in http://dymitruk.com/blog/2012/02/05/branch-per-feature/ specifically in the section titled "Taking features out is more powerful than putting them in". You may have difficulty if your features didn't start from the same commit (which, if you follow git-flow, they probably aren't). But you can try to make the best of it.
$ git checkout -b reduced_functionality_branch develop
$ git rebase -i sha1-for-previous-release-point
...remove the stuff you don't want...
At this point, reduced_functionality_branch should contain only the commits you want to be released.
You can use "git cherry-pick"
Please note that since you bring selective commits, commits must on source branch must be complete. You may get some merge conflicts as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With