github同步fork别人的项目到自己的仓库

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

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

https://help.github.com/articles/configuring-a-remote-for-a-fork/

完成同步

https://help.github.com/articles/syncing-a-fork/

以下中文版本

当我们fork一个项目后,在我们使用代码的时候就会以我们本地为准,不会跟随我们fork前的项目,如果需要同步对方的代码,需要进行同步操作

  • 首先我们先看下远端现有分支

ipandadeMBP:CMS ipanda$ git remote -v
origin    https://github.com/mpandar/CMS.git (fetch)
origin    https://github.com/mpandar/CMS.git (push)
  • 为fork的项目配置分支

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分支到本地

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分支

ipandadeMBP:CMS ipanda$ git checkout master
  • 同步到主分支

ipandadeMBP:CMS ipanda$ git merge upstream/master
Updating 569a184..eb4d63c
Fast-forward

Ok,即完成同步!

你可能感兴趣的:(github)