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

为君一笑 提交于 2020-01-13 19:49:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!