The instructions at https://cpython-devguide.readthedocs.io/gitbootcamp.html#syncing-with-upstream tell you how to pull changes into your forked repository and how to pull them into your branch that you may have made a PR out of. But it doesn't deal with rebasing your branch so that the code review on your branch does not contain extraneous changes when you have re-synced with the upstream repo.
This seems necessary in many PRs that go on for a while where you need to sync and merge across changes already made upstream (or potentially fix additional issues since introduced upstream in your PR).
I successfully used these instructions to rebase my branch used in my PR to get its diffs/changes back into a sane reviewable state again after I had already followed and pushed via the existing syncing with upstream instructions in my-branch:
https://www.digitalocean.com/community/tutorials/how-to-rebase-and-update-a-pull-request
Looking at my bash history, this involved:
git merge-base my-branch master to find the commit hash i wanted to rebase the branch off of.
git checkout my-branch
- git diff master >backup.diff` as I was entering new territory for me (relatively inexperienced git user).
- 'git rebase -i $hash_from_the_merge-branch_command_above` followed by not understanding why there were duplicate commits in my list. i suspect should've removed the later copies of those during this process; oops.
- many iterations of
git rebase --skip and git reset to skip past the duplicates that would otherwise show up as useless empty commits until the rebase was done.
- some final
git diff commands to confirm that it appeared to have worked.
git push origin my-branch
This should be able to be simplified. All of the rebase skipping and reset stuff was effectively manual recovery work from whatever state I had wound up in. I hope that is not normal if a rebase is done before making follow on changes after syncing with upstream. (?)
There may be other ways to do this. This is what I've happened to figure out so far.
The instructions at https://cpython-devguide.readthedocs.io/gitbootcamp.html#syncing-with-upstream tell you how to pull changes into your forked repository and how to pull them into your branch that you may have made a PR out of. But it doesn't deal with rebasing your branch so that the code review on your branch does not contain extraneous changes when you have re-synced with the upstream repo.
This seems necessary in many PRs that go on for a while where you need to sync and merge across changes already made upstream (or potentially fix additional issues since introduced upstream in your PR).
I successfully used these instructions to rebase my branch used in my PR to get its diffs/changes back into a sane reviewable state again after I had already followed and pushed via the existing syncing with upstream instructions in my-branch:
https://www.digitalocean.com/community/tutorials/how-to-rebase-and-update-a-pull-request
Looking at my bash history, this involved:
git merge-base my-branch masterto find the commit hash i wanted to rebase the branch off of.git checkout my-branchgit rebase --skipandgit resetto skip past the duplicates that would otherwise show up as useless empty commits until the rebase was done.git diffcommands to confirm that it appeared to have worked.git push origin my-branchThis should be able to be simplified. All of the rebase skipping and reset stuff was effectively manual recovery work from whatever state I had wound up in. I hope that is not normal if a rebase is done before making follow on changes after syncing with upstream. (?)
There may be other ways to do this. This is what I've happened to figure out so far.