我想尽可能清楚。例如,
步骤:
- 我正在开发branch1并提出了 pull 请求。
- 虽然此分支正在 PR 审批中,但我正在从分支 1 创建分支 2
- Branch1 获得批准并 merge 为开发分支
- 当我完成 Branch2 的工作后,我正在提高 PR。但是当人们查看我的 PR 时,它拥有来自branch1 的所有历史记录。
问题:我怎样才能(当我为已经 merge 的branch2和branch1提高PR时)只看到develop和branch2之间的差异,而不是develop和(branch1 +branch2)之间的差异。基本上,当人们查看我的branch2 PR 时,他们也必须寻找branch1,因为它是从branch1 创建的,但branch1 已经 merge 了。
最佳答案
When I finished work with branch2 I'm raising PR. But when people look at my PR it has all history from branch1 as suppose to have.
您需要做的就是git fetch uploaded
(假设git remote -v
列出upstream作为对您 fork 的原始存储库的引用)
(如果没有,请添加它:git remote add upper/url/of/original/repo
)
然后,您将在upstream/master之上重新设置您的branch2
(其中包括已接受并 merge 的branch1
代码)
git checkout branch2
git rebase upstream/master
git push --force
最后一条命令将使用新更新的分支覆盖 branch2
的历史记录。您的 branch2
的现有 PR 将自动更新。
它的差异历史记录将仅显示 branch2
提交,不再包括 branch1
提交。
关于git - 从没有提交历史记录的另一个分支创建分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46086814/