質問

Scenario:

I have a production (P) branch and my current (C) branch I created to work on some new features. Some of them are ready, however work on the rest will take more time than anticipated.

I would like to push to production (and merge with production (P) branch) features that are ready now, and then continue to work on the rest of them in my current (C) branch.

My Idea:

I can create new pre-production (PP) branch, remove all references to the code that is not ready in it and merge it to production (P) branch. Then I'll continue to work on current (C) branch and merge to production (P) branch when my work is ready.

Problem:

When I remove references in pre-production (PP) branch, there will be a lot of conflicts later when I merge my current (C) branch with production (P) branch. I'm afraid I can miss some important change in code. How can I do it better, avoiding conflicts? Merging is the power of Git, so my assumption is I don't know something important.

役に立ちましたか?

解決

You have made a mistake in your git flow and nothing elegant is there to salvage you anymore. Rather than trying to remove stuff from a branch created from C, the better solution is to create the PP branch from your P branch and cherry-pick the C branch into the new branch PP.

git checkout production
git pull
git checkout -b pre_production
git cherry-pick ...

Why? In your case you are going to have to go over the code in the branch C anyway and using your approach you would have to decide what's to be removed and what's to stay.

The solution for future cases, make your branches more feature oriented, that way you can only merge the features you really want.

ライセンス: CC-BY-SA帰属
所属していません softwareengineering.stackexchange
scroll top