日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

github中origin和upstream的区别(转)

發布時間:2025/5/22 编程问答 64 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)

  • 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

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

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的github中origin和upstream的区别(转)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。