github參考說明,英文好的直接看英文吧:git
https://help.github.com/articles/configuring-a-remote-for-a-fork/github
https://help.github.com/articles/syncing-a-fork/fetch
當咱們fork一個項目後,在咱們使用代碼的時候就會以咱們本地爲準,不會跟隨咱們fork前的項目,若是須要同步對方的代碼,須要進行同步操做code
首先咱們先看下遠端現有分支ip
ipandadeMBP:CMS ipanda$ git remote -v origin https://github.com/mpandar/CMS.git (fetch) origin https://github.com/mpandar/CMS.git (push)
爲fork的項目配置分支ci
ipandadeMBP:CMS ipanda$ git remote add upstream https://github.com/BootstrapCMS/CMS.git ipandadeMBP:CMS ipanda$ git remote -v origin https://github.com/mpandar/CMS.git (fetch) origin https://github.com/mpandar/CMS.git (push) upstream https://github.com/BootstrapCMS/CMS.git (fetch) upstream https://github.com/BootstrapCMS/CMS.git (push)
獲取upstream分支到本地rem
ipandadeMBP:CMS ipanda$ git fetch upstream remote: Counting objects: 4, done. remote: Total 4 (delta 3), reused 3 (delta 3), pack-reused 1 Unpacking objects: 100% (4/4), done. From https://github.com/BootstrapCMS/CMS * [new branch] 0.8 -> upstream/0.8 * [new branch] master -> upstream/master
切換到本地master分支get
ipandadeMBP:CMS ipanda$ git checkout master
同步到主分支同步
ipandadeMBP:CMS ipanda$ git merge upstream/master Updating 569a184..eb4d63c Fast-forward
Ok,即完成同步!it