GitHub更新自己Fork的项目

当GitHub上的源项目更新后,Fork的项目不会自动更新。本文以micmiu用户fork的sql-parser项目为例,介绍手动更新步骤:1) 克隆fork的分支;2) 添加远程原始分支到本地;3) 获取原始源分支的新版本;4) 合并代码;5) 提交更新到个人账号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自: http://www.tuicool.com/articles/MzMJre

github的fork可以将别人的工程复制到自己账号下。这个功能很方便,但其有一个缺点是:当源项目更新后,你fork的分支并不会一起更新,需要自己手动去更新。

以gitHub用户:micmiu (账号名),fork 项目 sql-parser(https://github.com/FoundationDB/sql-parser) 为例子:

1、clone 自己账号里fork的分支

git clone https://github.com/micmiu/sql-parser.git
cd sql-parser

2、增加远程原始分支到本地(可以用 git remote -v 命令查看远程分支列表)

$ git remote -v
origin  https://github.com/micmiu/sql-parser.git (fetch)
origin  https://github.com/micmiu/sql-parser.git (push)

如果没有远程原始分支则需要增加:

git remote add sql-parser_fdb https://github.com/FoundationDB/sql-parser.git

查看确认远程分支列表:

git remote -v
origin  https://github.com/micmiu/sql-parser.git (fetch)
origin  https://github.com/micmiu/sql-parser.git (push)
sql-parser_fdb  https://github.com/FoundationDB/sql-parser.git (fetch)
sql-parser_fdb  https://github.com/FoundationDB/sql-parser.git (push)

3、fetch原始源分支的新版本到本地

git fetch sql-parser_fdb

4、合并两个版本的代码

git merge sql-parser_fdb/master

5、把最新的代码提交到github自己(micmiu)的账号上

git push origin master
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值