git pull --rebase上游主服务器污染了我的Github PR差异 [英] git pull --rebase upstream master pollutes my Github PR diff

查看:204
本文介绍了git pull --rebase上游主服务器污染了我的Github PR差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我按照维护者的要求对我的PR进行更改之前,我先进行了git pull --rebase upstream master将我的提交放置在代码库中的其他新提交之上.

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.

但是,这似乎污染我的PR差异与其他提交的更改.

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

为什么会这样?
由于我的PR的基数是upstream/master,而我只有git pull --rebase upstream master,所以差异不应该只显示我的代码吗?

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?

推荐答案

我一直这样做,并且发现以下过程是解决问题的最佳方法:

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

为您要保存的PR中的所有提交(即您的提交)写下git commit散列.

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

然后运行以下命令:

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

它应该会自动修复您的PR

And it should fix your PR automatically

这篇关于git pull --rebase上游主服务器污染了我的Github PR差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆