Joff
Joff

Reputation: 12197

git: how to handle multiple branches, and pending pull requests

I've got a git repo fork.

I've made a branch branch-1 and have a pending PR on the origin/master

I want to fix another issue, which I think needs to be put in a new branch branch-2

branch-1 has some fixes that I would like to see in branch-2 (without branch 1, tests will not pass, and life will be annoying)

I don't want to wait for the PR to be merged to begin work on branch-2 in my fork.

How would you go about this situation without causing complications down the line...

Upvotes: 3

Views: 1316

Answers (1)

VonC
VonC

Reputation: 1329802

will that result in a headache down the line if the PR is merged, other commits come in on top of branch-1's merge commit and then I submit a PR for branch 2?

In that case (additional commits done on top of the accepted and merged branch-1), all you need to do is rebase branch-2 on top of the updated upstream/master (upstream reference the original repo you have forked)

 cd /path/to/your/repo
 git fetch upstream
 git reset master upstream/master
 git rebase --onto master branch-1 branch-2

That will rebase your local commits done from your local brnach-1 HEAD (excluded) up to your branch-2 HEAD (included) ontop of the updated original repo master.

Then you can force push branch-2; your existing branch-2 PR will be updated.

Upvotes: 1

Related Questions