Git workflow: how to merge commits made only on a new branch

We use git to track development versions and versions, and have encountered some issues with branch merging. Here is our workflow:

production/1.0.0 A--B stage/2.0.0 A--B--C--D development E--F--G--J--L \ feature H--I--K 

The development of functions takes place in the branches of the trait that was created from the development, and when the merge is ready for demonstration and testing.

All this works well, the problem is that the developer who created this function branch sends his function to the stage branch for deployment. Since they fork with development in G when they go to merge, it includes EFG when they want to combine HIK.

The goal of our git workflow is to give developers the ability to tag their own code for release, and to coordinate the fact that the entire development branch can be merged into a deployment branch, is not possible, as development takes place around the world.

Is there a git command to just merge commits made into function branches? I know that you need to reinstall and select from cherry, but a function can consist of a large number of merges with development merges that catch up with their functional branch. Is there a better solution?

Is this workflow right? Are we trying to do something that is not sustainable?

+5
source share
1 answer

This will be git rebase --onto combined with git merge-base :

 git checkout stage/2.0 git rebase --onto stage/onto $(git merge-base development feature) feature 

This will cause the feature branch to be feature again after G (which is the merge base commit between development and function) on stage/2.0 branch .

Result:

 stage/2.0.0 A--B--C--D \ feature H'--I'--K' development E--F--G--J--L 

The old H , I and K tags still refer to reflog ( git reflog ), but were selected by cherry and played over stage/2.0 .

Is this workflow right? Are we trying to do something that is not sustainable?

This, with the following reservations:
After such a reboot, it should include rigorous tests, because H , I and K , where it runs on top of G , which is generally absent in the stage/2.0 branch.

If these commits are dependent on G based content, this initial content will not be found in the intermediate branch. Some regression tests should make this obvious.

Using git cherry-pick (which can also play multiple commits), duplicate these commits to the intermediate branch, leaving the feature branch as it is (i.e. without reconnecting to the intermediate branch).
This seems strange, given that you will need to start which commits were selected by the cherry, and which other new feature commits have not yet been selected from the cherry for setting.


What happens if development is combined into a function between I and K ? (The developer caches his branch)
Will the cherry pick also include this union and all the code in the development branch along with it?

Yes, this will include a merge commit, but not the dev branch. In any case, this is not ideal. The best practice is not to merge dev with feature , but to swap feature on top of dev ( git rebase dev ).
Then, when the function is ready, rebase --onto stage/2.0


So what does the rebase --onto , basically move the function branch to stage/2.0.0 ?

Yes.

Is the feature branch disabled?

No: it is recreated by reapplying each commit fix on stage/2.0.0 .
The previous traits of the feature branches visible before rebase --onto are still present, but invisible, referenced only by git reflog , as mentioned above.

Nested $(git merge-base development feature) command $(git merge-base development feature) Does it use changes from function to development before moving branch to stage / 2.0.0 branch?

No: this is the calculation of the initial commit for this function branch, i.e.: development commit, from which the feature branch was started.
If I hadn’t used it, but a simple git rebase , the commit from the feature branch would include all the commits available from feature HEAD (and that would also include development )

+3
source

All Articles