简体   繁体   中英

Create pull request from same branch to multiple branches

We have a dev branch and master branch. When there is hotfix we checkout new branch say hotfix-1 from master and raise pull request to master branch. We also want to merge only this commit changes to the dev branch. So we would like to create a pull request from hotfix-1 to the dev branch too.

However, we are unable to do create a pull request from the same branch to dev because it is ahead and getting merge conflicts and if we update hotfix-1 with dev changes it will reflect master commit. What would be the solution to this? Do we need to create hotfix-dev-1 cherry-pick these latest commit changes and create a pull request to dev ? Any helps is greatly appreciated.

If we have new branch added in between say support should we need to create hotfix-2 ? Does this branching model scale when more number of long-lived branches introduced?

Do we need to create hotfix-dev-1 cherry-pick these latest commit changes and create a pull request to dev?

If a pull request (so I presume GitHub) is how the change gets into both of your branches: In short, yes. Pull request is to merge changes on the branch starting at the base it forked off from the target branch.

Well at least in the remote branch where you create a pull request. Locally, let's assume you got one commit on top of master which you want to have in dev . You can switch to dev:

git checkout dev

Perhaps make sure you're at the same state as the remote repo:

git pull

Cherry-pick HEAD of master:

git cherry-pick master

And now you can push it into the a new branch in the remote repository:

git push origin HEAD:refs/heads/hotfix-dev-1

You can create a PR against dev from that branch and you can locally reset your dev to its original state:

git reset --hard origin/dev

It doesn't really provide much advantage over just creating a branch to push from (and pruning it afterwards if you wish).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM