问题
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?
回答1:
After updating from upstream
you should update your origin
:
git push origin upstream/master:master
and then update your PR.
回答2:
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
来源:https://stackoverflow.com/questions/49969437/git-pull-rebase-upstream-master-pollutes-my-github-pr-diff