Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

In GitHub can I create a branch from a secondary branch and then merged it to main?

So I have the main branch.
I usually open a new branch to get some work done, let call this branch_1.

I have now finished my work on branch_1 and open a PR to main. But while I wait I want to do more work. This new work will use the branch_1 changes, but it will not mess around the same files, let’s call this branch_2.

I have now finished my work on branch_2 and open a PR to main, but this PR includes the commits from branch_1. And both PR are pending review.
Is there a way to have my branch_2 PR not include all these commits, but still work on top of branch_1 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If branch_2 is dependent on branch_1, then you have done things correctly. You need the commits from branch_1 if you want branch_2 to work, so you should include them.

If branch_2 can stand on it’s own, you should rebase it onto main and then submit the pull request. Use caution if rebasing when dependent on branch_1 features. The rebase will eliminate the branch_1 commits, but this may also mean branch_2 is now referencing non-existent code or using features that don’t yet exist.

If branch_2 is dependent on branch_1 and you don’t want to have a pull request that depends on another pull request, merge branch_2 into branch_1 and update the branch_1 pull request appropriately.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading