Let's say we have three different branches:
- Main Branch - Here the developer pushes new code changes for new features
- Release Branch - This is the Production Branch
- 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 hotfix1to
releasethere would be an option to select extra target branches for an automatically created cherry-pick to
main,
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