GitHub 上的 origin 和 upstream 有什么区别?

编程入门 行业动态 更新时间:2024-10-27 20:23:57
本文介绍了GitHub 上的 origin 和 upstream 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

origin 和 upstream 有什么区别>GitHub?

What is the difference between origin and upstream on GitHub?

当一个 git branch -a 命令被执行时,它显示的一些分支的前缀为 origin (remotes/origin/..) 而其他的前缀为 upstream (remotes/upstream/..).

When a git branch -a command is executed, some branches it displays have a prefix of origin (remotes/origin/..) while others have a prefix of upstream (remotes/upstream/..).

推荐答案

这应该在 GitHub 分叉(在本地克隆该分叉之前,您在 GitHub 上分叉一个 GitHub 存储库).

This should be understood in the context of GitHub forks (where you fork a GitHub repo on GitHub before cloning that fork locally).

  • upstream 一般是指你已经分叉的原始 repo(另见下游"和上游"的定义" 了解更多关于 upstream 术语)
  • origin 是你的 fork:你自己在 GitHub 上的 repo,是 GitHub 原始 repo 的克隆
  • upstream generally refers to the original repo that you have forked (see also "Definition of "downstream" and "upstream"" for more on upstream term)
  • origin is your fork: your own repo on GitHub, clone of the original repo of GitHub

来自 GitHub 页面:

From the GitHub page:

当一个 repo 被克隆时,它有一个名为 origin 的默认远程指向你在 GitHub 上的分叉,而不是它被分叉的原始 repo.要跟踪原始存储库,您需要添加另一个名为 upstream

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 named upstream

git remote add upstream git://github/<aUser>/<aRepo.git>

(使用 aUser/aRepo 引用您已经分叉的原始创建者和存储库)

(with aUser/aRepo the reference for the original creator and repository, that you have forked)

您将使用上游来从原始存储库中获取(以使您的本地副本与您要参与的项目保持同步).

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).

git fetch upstream

(git fetch 单独会默认从 origin 获取,这不是这里需要的)

(git fetch alone would fetch from origin by default, which is not what is needed here)

您将使用 origin 来拉取和推送,因为您可以为自己的存储库做出贡献.

You will use origin to pull and push since you can contribute to your own repository.

git pull git push

(同样,没有参数,默认使用'origin')

(again, without parameters, 'origin' is used by default)

您将通过制作 upstream 存储库"noreferrer">拉取请求.

You will contribute back to the upstream repo by making a pull request.

更多推荐

GitHub 上的 origin 和 upstream 有什么区别?

本文发布于:2023-10-08 02:22:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471234.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   GitHub   origin   upstream

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!