Chain of events after forking a repo:
I still have work to do on the PR, but now I have to rebase my branch on the branch that the repo owner created to test some things before my branch can be merged with his master.
How can I rebase the branch in my local repo with the branch created in the remote? I basically want one of my branches to be the same as one of the branches in the upstream repo (not master).
Apologies in advance for the potentially poor use of terminology.
How can I rebase the branch in my local repo with the branch created in the remote? I basically want one of my branches to be the same as one of the branches in the upstream repo (not master).
The usual way:
git rebase upstream/the_branch
This will change the history of your branch that you used in the PR. But that's fine. Since your PR is not accepted yet, and as you said it needs more work, it's ok to rewrite its underlying branch, when you're done, with:
git push -f origin yourbranch_for_pr
As a side note,
after this, in the PR you will see all your changes made before the rebase, and after, but also the other changes made by the repo owner if those changes were not yet merged into master
. It will be ideal if the repo owner merges his changes into master
first, and then your PR will contain only your work, which will be more clear.
If you want to sync your branch with upstream and you have really no commits locally that you want to keep, the easier is to reset:
git reset --hard upstream/the_branch
You could also specify directly a sha1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With