排除工作流以将上游更改合并到分叉存储库中

时间:2014-07-27 06:44:30

标签: git

我分叉了一个git repo,然后创建了一个名为“strlen。”的分支。

提交公关并进行建议更改后:。

以下是我尝试合并上游变更:

A部分:从上游获取和合并:

git fetch upstream
git merge upstream/master

B部分:压缩上游提交,仅为我的特定更改保留一个提交注释:

git rebase --interactive HEAD~2
  

注意:对于交互式部分,我对所有提交都进行了s(quash)   除了顶部的最新一个(我的)。

C部分:在github上将更改推回到我的分支:

 git push origin strlen

“壁球”似乎没有像这次宣传的那样做:所有干预提交**以及介入文件更改**都在strlen分支上可见。新的Pull请求显示了所有内容,而目的是仅显示我的文件更改。

所以,

的任何提示
  • (a)我应该以不同的方式执行rebase
  • 或(b)完全采取另一种方法

更新从VonC的最佳答案中,我添加了更多详细信息,这是当前的解决方案:

git remote add upstream https://github.com/foo/bar.git
git checkout master
git fetch upstream
git checkout strlen
# Make changes. If using IJ you can then create CL and commit the CL locally.
#   Alternatively simply use command line and do commit -m "Made some updates"
git rebase -i upstream/master  # Squash the newer commits into 
                               # the original one used to create the PR
git push -f origin

上述工作流程非常有效。实际上足以解决由我的原始工作流程引起的问题(合并错误)。

1 个答案:

答案 0 :(得分:2)

更新PR分支时,您不会合并upstream/master

您在更新的upstream/master

之上重新定位您的本地PR分支
git fetch upstream
git checkout strlen
git rebase -i upstream/master # you can squash if you want there
git push -f origin

您强制推送,但考虑到strlen分支的新历史记录,您的PR会自动更新。

详见:

相关问题