Skip to content

git boot camp syncing with upstream instructions need to rebase the branch for proper PR review #102

Description

@gpshead

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:

  1. git merge-base my-branch master to find the commit hash i wanted to rebase the branch off of.
  2. git checkout my-branch
  3. git diff master >backup.diff` as I was entering new territory for me (relatively inexperienced git user).
  4. '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.
  5. 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.
  6. some final git diff commands to confirm that it appeared to have worked.
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions