Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git pull --rebase upstream master pollutes my Github PR diff

Before I make a change to my PR, as requested by the maintainers, I do a git pull --rebase upstream master to place my commits on top of other new commits in the code base.

However, this seems to pollute the diff of my PR with changes from other commits.

Why is this happening?
Since the base of my PR is upstream/master, and I have just git pull --rebase upstream master, shouldn't the diff only show my code?

like image 753
Heisenberg Avatar asked Jan 23 '26 21:01

Heisenberg


1 Answers

I do this all the time and have found the following process the best way to solve it:

Write down the git commit hashes for all commits in the PR that you want to save (i.e. your commits).

Then run the following:

git fetch upstream
git reset --hard upstream/master
git cherry-pick <hash 1>
git cherry-pick <hash 2>
// cherry-pick all of your commits then:
git push -f origin your-branch

And it should fix your PR automatically

like image 65
E.Arrowood Avatar answered Jan 26 '26 12:01

E.Arrowood