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:

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

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

相关推荐
研究点啥好呢3 小时前
Github热门项目推荐 | 创建你的像素风格!
c++·python·node.js·github·开源软件
无限进步_4 小时前
【C++】电话号码的字母组合:从有限处理到通用解法
开发语言·c++·ide·windows·git·github·visual studio
MicrosoftReactor4 小时前
技术速递|使用 Copilot SDK 构建 AI 驱动的 GitHub Issue 分类系统
人工智能·github·copilot
AI成长日志4 小时前
【GitHub开源项目专栏】AI推理优化框架深度解析(上):vLLM架构设计与核心实现
人工智能·开源·github
CV-deeplearning5 小时前
【开源】字节跳动开源 DeerFlow 2.0:一站式 SuperAgent 开发框架,GitHub 星标 5.9 万!
开源·github·deerflow·deerflow 2.0·superagent
Freak嵌入式6 小时前
MicroPython LVGL基础知识和概念:显示与多屏管理
开发语言·python·github·php·gui·lvgl·micropython
zandy10116 小时前
【全新 3.0版本】openclaw github installation guide
github·openclaw·installation
Freak嵌入式7 小时前
MicroPython LVGL基础知识和概念:时序与动态效果
开发语言·python·github·php·gui·lvgl·micropython
北冥有羽Victoria8 小时前
OpenCLI 操作网页 从0到1完整实操指南
vscode·爬虫·python·github·api·ai编程·opencli
Thomas.Sir8 小时前
GitHub Copilot从入门到精通【从基础补全到智能代理,解锁AI编程全技能】
github·copilot·ai编程