前馈科技

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 23568|回复: 0

github更新线上fork的仓库

[复制链接]

97

主题

97

帖子

539

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
539
发表于 2022-6-5 19:40:37 | 显示全部楼层 |阅读模式
fork到自己的仓库后,后续正式版本标签就不同步到该仓库了,我们想在本地切换到最新的release版本就比较麻烦,我们需要跟新fork库
1、查看upstream和origin设置是否正确:git remote -v

origin    https://ghp_ojEjyPi1Kq6NcRlIk1Wy ... incubator-nuttx.git (fetch)
origin    https://ghp_ojEjyPi1Kq6NcRlIk1Wy ... incubator-nuttx.git (push)
upstream    https://github.com/zouboan/incubator-nuttx.git (fetch)
upstream    https://github.com/zouboan/incubator-nuttx.git (push)

可见upstream不正确,需要重新设置
2、 设置upstream:  git remote add upstream https://github.com/apache/incubator-nuttx.git
结果报错了:fatal: remote upstream already exists.
我们需要删除它重新设置:
git remote rm upstream
git remote add upstream https://github.com/apache/incubator-nuttx.git

重新查看:git remote -v   结果如下:
origin    https://ghp_ojEjyPi1Kq6NcRlIk1Wy ... incubator-nuttx.git (fetch)
origin    https://ghp_ojEjyPi1Kq6NcRlIk1Wy ... incubator-nuttx.git (push)
upstream    https://github.com/apache/incubator-nuttx.git (fetch)
upstream    https://github.com/apache/incubator-nuttx.git (push)
这次对了

3、fetch源分支的新版本到本地[master]>
    git fetch upstream
4、合并两个版本的代码
    git merge upstream/master
5、将合并后的代码push到github上去
   git push origin master

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|计算机控制

GMT+8, 2024-4-26 15:46 , Processed in 0.049956 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表