github中origin和upstream的区别(转)

 
Fork,本身并不是git工具中的一个命令,也不是对git的扩展,它是在GitHub上的概念,是另一种clone方式——在服务器端的clone
而我们通常意义上的clone,是将远程repo 复制一份到本地。

当你从GitHub上 clone 一个 repo 到本地时,除非你已明确声明是这个repo的contributor,否则你是不能向其pull request的,此时,该远程的repo对于本地repo来说,就是upstream。
当你从GitHub上 fork 一个 repo 之后,再 clone forked repo 到本地,你就可以任意向其pull request,此时,远程的 repo 就是 origin。

下面一段是来自 GitHub pages 的解释:

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.com/user/repo_name.git

总结下来: 
1. 如果是 upstream repo,你只可以拉取最新代码(即 git fetch ),从而保证你本地的仓库与源仓库同步 
2. 如果是 origin repo,就是你自己的repo(自己创建的,或者 fork 的项目)你可以做 任何推拉操作(pull and push) 
3. 你可以通过 pull request 向 upstream repo 贡献代码

Referenced by http://stackoverflow.com/questions/6286571/git-fork-is-git-clone

In terms of source control, you're "downstream" when you copy (clone, checkout, etc) from a repository. Information flowed "downstream" to you.

When you make changes, you usually want to send them back "upstream" so they make it into that repository so that everyone pulling from the same source is working with all the same changes. This is mostly a social issue of how everyone can coordinate their work rather than a technical requirement of source control. You want to get your changes into the main project so you're not tracking divergent lines of development.

Sometimes you'll read about package or release managers (the people, not the tool) talking about submitting changes to "upstream". That usually means they had to adjust the original sources so they could create a package for their system. They don't want to keep making those changes, so if they send them "upstream" to the original source, they shouldn't have to deal with the same issue in the next release.

http://stackoverflow.com/questions/2739376/definition-of-downstream-and-upstream/2749166#2749166

What is the difference between origin and upstream in 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/..).
================

 

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

From the GitHub page:

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.com/user/repo.git

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

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

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

http://my.oschina.net/uniquejava/blog/481625

时间: 2024-07-30 20:37:52

github中origin和upstream的区别(转)的相关文章

web context j2ee-j2ee中的各种context的区别?

问题描述 j2ee中的各种context的区别? 比如applicationcontext,sessioncontext,servletcontext,requestcontext,responsecontext,pagecontext这几个context.上面可能没有列举完,希望大神可以详细地解答一下~ 解决方案 同样小白,我自己的理解就是他们的作用域范围不太一样吧.

安卓线程中 stopSelf();和ondestroy()的区别

问题描述 安卓线程中 stopSelf();和ondestroy()的区别 在runnable分别加入ondestroy()和stopself(); 在断点中下面的代码都执行了, 但是再一次startservice(线程)的时候前者提示Thread is started异常, 后者则正常 @Override public void onDestroy(){ super.onDestroy(); ListData.interrupt(); } 解决方案 interrupt()并不会真正结束掉线程.

mfc-关于MFC中nEscapement和nOrientation的区别和用法

问题描述 关于MFC中nEscapement和nOrientation的区别和用法 我使用的是cEscapement的方式调整字体角度,结果是以每行的首字为原点的角度变化,即如果换行了,文字变换角度是对的但上下两行仍然是对齐的. 有没有什么办法使得角度变换后能够将整个字体作为整体一起改变. (_T("字体角度") == strName) { lf.lfEscapement = _ttol(strVal) *10; pText->m_pFont = pText->m_pLay

PHP中exit()与die()的区别

本篇文章简要分析一下在php中经常用到的exit和die的区别,有需要的朋友可以看一下. 首先思考一个问题: 如下代码会向页面显示什么? <?php die(123); ?> 曾经有段时间我一直认为 页面会显示 123,但实践结果告诉我,答案错了,页面一片空白! 一直不知道为什么,死活不输出123,为了让页面输出123,我把它修改为如下代码: <?php echo '123'; die(); ?> 网上的一段资料: PHP中exit()与die()的区别 PHP手册:die()Eq

javascript中call和apply的区别

我理解javascript中call和apply的区别仅在于语法不同. 下例中分别调用call和apply对myObj进行修改,语法不同,但使用效果是一样的: var myObj = { "a":1, "b":2, "c":3 } var myFunc = function(a,b,c){ this.a=a; this.b=b; this.c=c; } myFunc.call(myObj,4,5,6);//参数个数无限制 iJs.showObje

MySQL中int和integer的区别

环境: MySQLSever 5.1 问题:MySQL 中int和integer什么区别 答案:没有区别 分析: · INT[(M)][UNSIGNED] [ZEROFILL] 普通大小的整数.带符号的范围是- 2147483648到2147483647.无符号的范围是0到4294967295. ·INTEGER[(M)] [UNSIGNED] [ZEROFILL] 这是INT的同义词.使用两个名字只是为了简化和方便,没有本质上的区别. 查看本栏目更多精彩内容:http://www.biance

ASP.NET中Session和Cache的区别总结

  这篇文章主要介绍了ASP.NET中Session和Cache的区别总结,本文结合使用经验,总结出了5点Session缓存和Cache缓存的区别,需要的朋友可以参考下 以前实现数据的缓存有很多种方法,有客户端的Cookie,有服务器端的Session和Application.其中Cookie是保存在客户端的一组数据,主要用来保存用户名等个人信息.Session则保存对话信息.Application则是保存在整个应用程序范围内的信息,相当于全局变量.通常使用最频繁的是Session,那么Sess

JavaScript中Null与Undefined的区别解析

  这篇文章主要介绍了JavaScript中Null与Undefined的区别解析,本文给出了多个代码实例讲解它们之间的区别,需要的朋友可以参考下 在JavaScript中存在这样两种原始类型:Null与Undefined.这两种类型常常会使JavaScript的开发人员产生疑惑,在什么时候是Null,什么时候又是Undefined? Undefined类型只有一个值,即undefined.当声明的变量还未被初始化时,变量的默认值为undefined. Null类型也只有一个值,即null.nu

VB中Byval和byref的区别

在VB中Byval 和byref怎么区别?简单来说Byval是传值,byref是传地址,ByVal :表示该参数是按值方式传递的.ByRef :表示该参数按引用方式传递.下面绿茶小编为大家详细介绍Byval 和byref的区别. 1.引用参数(ref)在可以作为引用参数在函数成员调用中传递之前,必须已明确赋值,而输出参数(out)在可以作为输出参数在函数成员调用中传递之前不一定要明确赋值,在该函数成员正常返回前都必须已明确赋值. 2.在函数内部,引用参数(ref)被视为初始已赋值,输出参数(ou