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:

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

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

相关推荐
深耕AI34 分钟前
【宝塔面板】监控、日志、任务与安全设置
安全·github
~~李木子~~7 小时前
通过git上传项目到码云和GitHub操作手册
git·gitee·github
AI分享猿10 小时前
雷池 WAF 免费版实测:企业用 Apache 搭环境,护住跨境电商平台
web安全·github·apache
whysqwhw12 小时前
kotlin-4
github
whysqwhw12 小时前
kotlin-3
github
whysqwhw12 小时前
kotlin-1
github
whysqwhw12 小时前
kotlin-2
github
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2025-11-09)
github
labview_自动化14 小时前
GitHub笔记
笔记·github
知行力15 小时前
【GitHub每日速递 20251111】PyTorch:GPU加速、动态网络,深度学习平台的不二之选!
pytorch·深度学习·github