git GitHub 上的 origin 和 upstream 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9257533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between origin and upstream on GitHub?
提问by jan
What is the difference between origin
and upstream
on GitHub?
origin
和upstream
on GitHub 有什么区别?
When a git branch -a
command is done, some branches have a prefix of origin
(remotes/origin/..
) while others have a prefix of upstream
(remotes/upstream/..
).
当一个git branch -a
命令完成时,一些分支的前缀为origin
( remotes/origin/..
) 而另一些分支的前缀为upstream
( remotes/upstream/..
)。
回答by VonC
This should be understood in the context of GitHub forks(where you fork a GitHub repo on GitHub before cloning that fork locally).
这应该在GitHub 分叉的上下文中理解(在本地克隆该分叉之前,您在 GitHub 上分叉一个 GitHub 存储库)。
upstream
generally refers to the original repo that you have forked
(see also "Definition of “downstream
” and “upstream
”" for more onupstream
term)origin
is your fork: your own repo on GitHub, clone of the original repo of GitHub
upstream
通常是指您分叉的原始存储库
(有关术语的更多信息,另请参阅“downstream
”和“upstream
”的定义upstream
)origin
is your fork: 你自己在 GitHub 上的 repo,是 GitHub 原始 repo 的克隆
From the GitHub page:
从 GitHub 页面:
When a repo is cloned, it has a default remote called
origin
that points to your fork on GitHub, not the original repo it was forked from.
To keep track of the original repo, you need to add another remote namedupstream
当一个 repo 被克隆时,它有一个默认的远程调用
origin
,它指向你在 GitHub 上的 fork,而不是它被 fork 的原始 repo。
要跟踪原始存储库,您需要添加另一个名为的远程upstream
git remote add upstream git://github.com/<aUser>/<aRepo.git>
(with aUser/aRepo
the reference for the original creator and repository, that you have forked)
(aUser/aRepo
参考您已经分叉的原始创建者和存储库)
You will use upstream
to fetch from the original repo(in order to keep your local copy in sync with the project you want to contribute to).
您将使用upstream
到从原来的回购取(为了保持你的本地副本同步与您想参与该项目)。
git fetch upstream
(git fetch
alone would fetch from origin
by default, which is not what is needed here)
(默认情况下git fetch
单独会从中获取origin
,这不是这里需要的)
You will use origin
to pull and pushsince you can contribute to your own repository.
您将使用origin
到推拉因为你可以贡献自己的资源库。
git pull
git push
(again, without parameters, 'origin' is used by default)
(同样,没有参数,默认使用'origin')
You will contribute back to the upstream
repo by making a pull request.
您将upstream
通过发出拉取请求来回馈仓库。