We have moved from IBM RTC to Git recently and facing a problem with branching strategy. We use to have three streams in RTC Jazz, Development flows to Staging & Staging flows in Production. While moving to Git(Azure Repos) we placed RTC component(multiple Web Service projects) in one big mono repo & opted for GitLab Flow branching strategy due to it's emphasis on long lived environment branches(three branches, one for each environment). As we have three environments & we want to keep track of what code is deployed to which environment and there can be different versions of same web service on three environments.
The workflow we decided was for developer to branch out feature branch from production branch and start working and then sequentially merge his/her feature branch to development , staging and finally production.
This was working good initially but later when we raise PR to merge feature branch into one of development and staging branch then unwanted commits become part of PR as the feature branch also contains commits which we merged into production after the branch out of development and staging branch. PR Commits, Green wanted, Red unwanted
I don't know that we're not following the GitLab flow correctly or there is some problem in our workflow?
Constraints:
- We can not fallow linear flow by merging development to staging & staging to production as we have mono repo and we don't wanna move everything at once.
- We want to retain the code of each environment on each branch.
If you want to push changes to a target branch via PR, it is generally recommended to create the source branch based on the target branch. Then make changes on the source branch and raise PR to merge the changes to the target branch. During the process, avoid as possible pushing some other changes to the target branch from other processes. This could ensure the source branch is up to date with the latest target branch and avoid conflicts and unexpected changes.
For your case, since you create the
featurebranch based on theproductionbranch, you can try to use cherry-pick to copy the wanted changes fromfeaturetodevelopmentorstagingbranch.Raise a temporary PR from
featuretoproduction.featurebranch that should be the wanted changes.Ensure there is no conflict between
featureand the target branch (developmentorstagingbranch for your case) that you want to merge the wanted changes to. If conflict exists, resolve it at first.On the menu of the temporary PR, select '
Cherry-pick' option. On the pop-up window, select the target branch (e.g,development) that you want to merge the wanted changes to. Then click 'Cherry-pick' button.After clicking '
Cherry-pick' button, the system will do the following things.feature-on-development' if you selected to cherry-pick changes fromfeaturetodevelopment.feature-on-developmenttodevelopment.Complete the PR created by step
#4. Then you can delete any temporary branches and close/abandon any temporary PR.