在GitHub上 origin 和 upstream 有什么区别?
origin
upstream
完成 git branch -a 命令后,某些分支的前缀为 origin ( remotes/origin/.. ),而其他分支的前缀为 upstream ( remotes/upstream/.. ) .
git branch -a
remotes/origin/..
remotes/upstream/..
这应该在 GitHub forks (在本地克隆该fork之前在GitHub上分叉GitHub存储库)的上下文中理解 .
upstream 通常是指您已分叉的原始仓库(有关 upstream 术语的更多信息,另请参阅“Definition of “downstream” and “upstream””)
origin 是你的叉子:你自己在GitHub上的回购,克隆了GitHub的原始回购
从GitHub页面:
当一个repo被克隆时,它有一个默认的远程名为origin,指向你在GitHub上的fork,而不是它分叉的原始repo . 要跟踪原始仓库,您需要添加另一个名为upstream的远程
git remote add upstream git://github.com/user/repo.git
您将使用 upstream 至 fetch from the original repo (以使本地副本与您要贡献的项目保持同步) .
git fetch upstream
( git fetch 默认情况下会从 origin 获取,这不是这里需要的)
git fetch
您将使用 origin 至 pull and push ,因为您可以为自己的回购做出贡献 .
git pull git push
(同样,没有参数,默认使用'origin')
您将通过制作 pull request 回馈 upstream 回购 .
1 回答
这应该在 GitHub forks (在本地克隆该fork之前在GitHub上分叉GitHub存储库)的上下文中理解 .
upstream
通常是指您已分叉的原始仓库(有关
upstream
术语的更多信息,另请参阅“Definition of “downstream” and “upstream””)origin
是你的叉子:你自己在GitHub上的回购,克隆了GitHub的原始回购从GitHub页面:
您将使用
upstream
至 fetch from the original repo (以使本地副本与您要贡献的项目保持同步) .(
git fetch
默认情况下会从origin
获取,这不是这里需要的)您将使用
origin
至 pull and push ,因为您可以为自己的回购做出贡献 .(同样,没有参数,默认使用'origin')
您将通过制作 pull request 回馈
upstream
回购 .