Home > Back-end >  How to create multiple Pull requests for the same changes on multiple branches
How to create multiple Pull requests for the same changes on multiple branches

Time:01-09

Let's say we have three different branches:

  1. Main Branch - Here the developer pushes new code changes for new features
  2. Release Branch - This is the Production Branch
  3. Demo Branch - This branch is used to demonstrate new features to the customers.

So now the problem is that whenever I need to provide a hotfix to an escalation on the release branch, I have to create three different PR manually each for the Main, Release, and Demo branches for the same changes which is quite a manual task and a bit frustrating.

Currently, I commit the changes to the Release branch and cherry-pick the commits to the other branches, and create separate PRs for all these three branches.

Is there any way to create multiple PRs for the same change for multiple branches in one go?

Appreciate your help or any suggestion Thanks!

CodePudding user response:

There is no feature like this.

A pull request is from a branch to a branch (a pr is not for a commit) and a pr from hotfix1 branch (based on release branch) to release if 'repeated' onto main and/or demo will yield undesirable results in most cases. 'Repeating' a PR into multiple branches is not the same as cherry-picking a hotfix commit (the cherry-pick PR creates a 'temp' branch from the target branch).


How this could work

Let's say that the feature works for single commit PRs only for simplicity. When creating the PR from hotfix1toreleasethere would be an option to select extra target branches for an automatically created cherry-pick tomain, demo`, etc. I suppose this would be possible, but GitHub doesn't have it at the moment.

CodePudding user response:

You can use the Github CLI and a bash script to create PRs to multiple branches. For example:

for branch in main release
do
   gh pr create -B $branch -t "My PR title" -b "My PR description"
done
  • Related