github上将源repo提交更新到fork的repo

在github上 一般我们都是将别人的repo fork到自己的github repo。 然后阅读,修改 甚至是contribution。所以同步源repo的commit 尤为重要。因为你要始终保持与源repo同步。下面将描述下怎么去同步更新的步骤。

1. 将源repo https link 加到自己本地 repo 的remote upstream中。添加之后,如果你想查看是否加入成功。可以使用git remote -v

git remote add upstream https://github.com/ORIGINAL_OWENER/ORIGINAL_REPO.git

2. fetch 源repo的最新提交到本地, 然后merge到自己的repo

git fetch upstream
git checkout master   #if you current branch isn't master
git merge upstream/master


Or use following one command replace above three commands

git pull upstream master

#upstream represents remote source repo
#master represents master branch of the forked repo 

3. 将自己repo的合并后的,提交到github上。

git push origin master 

Note: 如何强制 覆盖github上的commit

# add -f is ok
git push -f origin master   

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值