github同步fork别人的项目到本身的仓库

github参考说明,英文好的直接看英文吧:git

先保证有对fork的项目有一个远程分支

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

相关文章
相关标签/搜索