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,即完成同步!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值