Github进行fork后如何与原仓库同步[解决git clone 太慢的问题]

前言

fork了一个仓库以后怎么同步源仓库的代码?

先说一下git clone太慢的问题,可以通过代理拉取代码,具体请看:

https://gitclone.com/

步骤

1、执行命令 git remote -v 查看你的远程仓库的路径。

以一个实际例子说明,

来源仓库:

javascript 复制代码
TheFirstLineOfCode/basalt
bash 复制代码
git remote -v

得到:

bash 复制代码
origin	https://github.com/ghmin/basalt (fetch)
origin	https://github.com/ghmin/basalt (push)

上游代码库:

bash 复制代码
https://github.com/TheFirstLineOfCode/basalt.git
bash 复制代码
git remote add fork  https://github.com/TheFirstLineOfCode/basalt.git

再查看信息可以看到:

ps:3、如果代码有修改,需要先切换到master或者分支中,并且提交到本地对应分支。

bash 复制代码
# 切换到对应分支
git checkout master

# 提交代码到对应本地仓库
git add -A 或者 git add filename
git commit -m "your note"
git push origin master

抓取源原仓库的更新。

bash 复制代码
git fetch fork

合并分支

bash 复制代码
-- 合并源仓库的master分支到本地仓库。如果遇到冲突,在本地就先将冲突解决了
git merge fork/main
ps:之前国外有master/slave什么的运动,导致github上面主版本都不叫master,就叫main了。

本地仓库向github仓库。

git push

在仓库中发起 pull request 合并到源仓库

这一步需要在网页中操作,以fork仓库中添加了一个文件为例子,说明如何请求merge:

当然,不是真的merge到源仓库里面去,只是示范一下。

首先请更新到fork仓库中去:

ps:如果idea一直显示 push,那就是网速问题了,也可能是根本推不上去。

bash 复制代码
GnuTLS recv error (-110): The TLS connection was non-properly terminated

权宜之计:

bash 复制代码
## 设置这个仓库不校验 https了。
git config  http.sslVerify false

注意,可能还有验证方式的,比如,要你输入userToken:

生成填写以后,顺利的话将更新成功,可以看到:

好了,下面示范一下怎么请求合并:

相关推荐
icebreaker3 小时前
tailwindcss 究竟比 unocss 快多少?
前端·css·github
Giant1006 小时前
小白也能看懂的 Git 命令手册:从配置到提交,一步到位
github
ruanCat10 小时前
使用 vite 的 base 命令行参数来解决项目部署在 github page 的路径问题
前端·github
FreeBuf_10 小时前
Salesloft Drift网络攻击事件溯源:GitHub账户失陷与OAuth令牌窃取
安全·github
第七种黄昏10 小时前
GitHub 项目提交完整流程(含常见问题与解决办法)
github
确定过眼神!12 小时前
GitHub提交到公共项目流程
github·changeset
掘我的金12 小时前
mpc4j 在 macOS M3(Apple Silicon)上的部署实录:JDK 21(Preview)与 FourQ 缺失排错
github
油泼辣子多加14 小时前
[特殊字符] GitHub 热门开源项目速览(2025/09/09)
github
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2025-09-09)
ai·开源·大模型·github·ai教程
BillKu15 小时前
下载 Eclipse Temurin 的 OpenJDK 提示 “无法访问此网站 github.com 的响应时间过长”
github·openjdk·eclipse temurin