Git 如何合并其他 Remote 上面的更新

來源:互聯網
上載者:User

在 Github 上面 Fork 別人的項目時,我們常常會遇到主專案有了更新,這個時候怎麼把主專案的更新合并到自己 Fork的版本裡面來呢? 今天突然有人問我這個問題,這裡就寫出來。
下面以 ruby-china 這個項目為例,假設我是使用者@tualatrix,
並且我有一個 ruby-china 的 fork版本在 這裡 ,而這個時候我在本地的版本是 tualatrix/ruby-china 這個

# 我先吧 tualatrix Fork 的版本擷取到本地~/work $ git clone git://github.com/tualatrix/ruby-china.git~/work $ cd ruby-china~/work/ruby-china <master> $ git remoteorigin# 添加 huacnlee (也就是主專案的 remote 地址)~/work/ruby-china <master> $ git remote add huacnlee git://github.com/huacnlee/ruby-china.git# 用 fetch 命令擷取 huacnlee 的所有分支~/work/ruby-china <master> $ git fetch huacnleeremote: Counting objects: 499, done.remote: Compressing objects: 100% (143/143), done.remote: Total 315 (delta 211), reused 253 (delta 172)Receiving objects: 100% (315/315), 190.17 KiB | 92 KiB/s, done.Resolving deltas: 100% (211/211), completed with 72 local objects.From git://github.com/huacnlee/ruby-china * [new branch]      master -> huacnlee/master# 將 huacnlee 的 master 分支的改動合并過來,目前是處與 master 分支~/work/ruby-china <master> $ git merge huacnlee/master

git remote update 則是更新所有遠程倉庫,使它們保持一致。例如有 origin 和 korg 兩個遠程倉庫,git remote update之後,兩個保持一致,且所有分支一致。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.