Upstream Fetch vs Rebase on Development Branch in Git/Github

I am trying to learn more on git / github merging in upstream changes relative to a branch/PR as part of my recent work,

I’ve forked “my repo” on github from an “upstream repo”
I’ve cloned “my repo” locally.
I’ve created “my local branch” and started to develop updates on “my local repo”.
I’ve completed initial work, committed to “my local repo” on “my local branch” then pushed to “my repo” to equivalent “my repo branch”
I’ve created “My PR” against “uppstream repo” based on my changes in “my repo” from “my repo branch”
As “My PR” was awaiting review, more changes were made on the master “upstream repo”, so there are commit differences between master and “my repo” - “my repo branch” as reflected in “My PR”.

When attempting to bring in the more recent commits previous, I’ve fetched and merging the changes (I believe in accordance to [1]), and then commited to my repo branch, which I believe resulted in a lot of changes being associated with the PR, which are not directly related ( i.e. working on “bug fix x relating to feature a” and pulling down “fixes for feature b” which then get’s included in “My PR”) which maybe I didn’t do quite right.

The github PR should only contain “fixes associated with the PR” and not others.

Should I just fetch upstreams, merge onto my branch? Assume this may be part of my misunderstanding and or something done incorrectly may be why some of the upstream commits are showing up in the PR/branch but not 100% sure here.

This may be related to dealing with remote changes[2] and dealing with “non-fast forwarded” type changes [3] but not sure if it’s quite right or maybe I missed something along the line.

I assumed this may be a candidate for “rebasing” of “my changes” in some way but this practice is still a little confusing to me (i.e. for example, should this be rebasing or merging, if rebasing, should I be “rebasing master onto my branch” or “rebasing my branch onto master”?)

When rebasing, should git “onto” switch be used in some way?

Is it possible to “rebase” via github those upstream master changes to my repos branch without showing as “changes as part of the branch”?

Hope this all makes senses…

I think I’m close to understanding this but still trying to get my head around some of the lower level details.

Eric

(1) Syncing a fork - GitHub Docs
(2) Pushing commits to a remote repository - GitHub Docs
(3) Dealing with non-fast-forward errors - GitHub Docs

Merging upstream changes into your branch should work to bring your branch up to date and resolve any conflicts, yes. Whether it’s the preferred option depends on how you (or upstream) want to work with branches, which is at least partly a matter of opinion.

That is the other common option here, yes. You’d be rebasing your changes on top of the upstream branch. Rebasing basically means to (automatically) recreate the commits that are only on your branch starting from the branch you’re rebasing onto. For a detailed description, see Git - Rebasing.

I don’t think it’s possible via the web UI.