You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Fork后,如何对比自有分支与上游仓库分支?含Web及CLI方案

对比Fork分支与上游分支变更的方法

GitHub Web界面操作步骤

  • 打开你的Fork仓库页面,切换到目标分支property-source
  • 点击页面上方的Compare按钮(位于"Code"按钮旁)
  • 在对比页面调整两端分支:
    • 左侧选择上游仓库springframeworkguru/sfg-di的property-source分支
    • 右侧选择你自己仓库steranka/udemy-sfg-di的property-source分支
  • 页面会直接展示两个分支的所有差异,无需创建Pull Request

提示:如果Web端没有自动显示上游仓库选项,可直接访问手动构造的对比URL:https://github.com/springframeworkguru/sfg-di/compare/property-source...steranka/udemy-sfg-di:property-source

gh-cli(GitHub命令行)实现方式

确保已安装并登录gh-cli,执行以下命令:

# 终端直接展示差异
gh repo compare springframeworkguru/sfg-di:property-source...steranka/udemy-sfg-di:property-source

# 或直接在浏览器打开对比页面
gh repo compare springframeworkguru/sfg-di:property-source...steranka/udemy-sfg-di:property-source --web

Git CLI本地对比(可选)

若偏好本地终端操作,可执行:

# 拉取上游仓库最新代码
git fetch upstream
# 对比本地分支与上游对应分支的差异
git diff upstream/property-source property-source

内容的提问来源于stack exchange,提问作者PatS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 18:40:43