Question

upstream:

A -- B -- C | develop

I fork upstream and make a new branch (patch)

   P1       | patch
 /
C           | develop

I then submit a pull request. Since upstream won't merge my PR quickly, I merge my patch branch on the local develop branch to start using my work.

   P1       | patch
 /    \
C  -- P2    | develop

Then upstream does some changes to develop:

A -- B -- C -- D -- E

I do "git fetch upstream", now I have:

             P1       | patch
           /    \
A -- B -- C  -- P2    | develop
           \
            D -- E    | upstream/develop

And I want:

                       P1     | patch
                     /    \
A -- B -- C -- D -- E  -- P2  | develop

I tried to do a "git rebase -p upstream/develop" from develop which gives me exactly this history except for the name of the "patch" branch which gets lost.

Was it helpful?

Solution

I solved removing the last commit on my local develop branch (P2) with:

git checkout develop
git rebase -i HEAD~2

In this way I can do a simple fast forward on the develop branch

git pull upstream develop

Now I can rebase my patch branch, and eventually redo the merge.

git checkout patch
git rebase upstream/develop

git checkout develop
git merge --no-ff patch

I don't know if this is the best way to do it, so I am waiting to close the question.

OTHER TIPS

Since you created the pull-request against your patch branch, you can go with:

git checkout patch
git rebase upstream/develop
git push origin patch

This will update the pull-request with your new rebased patch.

(assuming the pull-request is on github)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top