美文网首页
解决 git push 速度慢的问题

解决 git push 速度慢的问题

作者: 姚远_HIT | 来源:发表于2024-03-05 23:19 被阅读0次

前言

今天上传本地代码到远程 github 仓库的时候,使用 git push 速度非常上,上传速度只有 10 KB/s左右。遂上网查找解决方案,找到了一篇博文,最后成功解决上述速度慢的问题,以此记录,以防遗忘~~~

解决方案:修改本地的 hosts 文件

基本思想:"git clone" 或 "git push" 操作特别慢,这并非由于 "http://github.com" 这个域名受到限制。实际上,是因为 "http://github.global.ssl.fastly.net" 这个域名被限制了。为了解决此问题,首先需要找到这个域名的 IP 地址,然后在本地的 hosts 文件中创建该 IP 地址到域名的映射即可。这样,当你执行 "git clone" 或 "git push" 等操作时,你的电脑就会直接使用映射的IP地址来连接GitHub,从而绕过域名限制,提高操作速度。以下是具体步骤。

1. 修改本地hosts文件

windows系统的hosts文件的位置如下:C:\Windows\System32\drivers\etc\hosts

mac/linux系统的hosts文件的位置如下:/etc/hosts

2. 增加 github.global.ssl.fastly.net 和 github.com 的映射

a. 访问 https://www.ipaddress.com,找到页面中下方的 IP Address Lookup,如下图所有

b. 分别输入 github.global.ssl.fastly.net 和 github.com,查询到它们各自对应的 ip 地址,下图是我的网络对应的 IP 地址。

c. 按照上图找到的 IP 地址,分别将其写入到 C:\Windows\System32\drivers\etc\hosts (Windows)或 /etc/hosts (Mac) 中,即可:

199.232.69.194 github.global.ssl.fastly.net
140.82.112.4 github.com

参考博文

[1] 完美解决github访问速度慢

相关文章

  • git 常见问题

    问题1 : git push 问题 解决方案 git pull --tags -f解决地址: https://gi...

  • git 简单使用

    git push错误failed to push some refs to的解决 解决方案 这个问题是因为远程库与...

  • 解决git push问题

    push代码遇到如下问题: push origin master 没有权限 的时候,terminal报错没有权限。...

  • 2019-07-04

    git push :报错 413 Request Entity Too Large。 解决方案:git push ...

  • git permission deny 问题解决

    针对ATOM 的git plus, Mac电脑,git 配置完成后,atom 内的git-push无效问题的解决方...

  • 3.Git常见问题

    1.failed to push some refs to git 'git地址' 问题详情:$ git push...

  • git一些小问题解决

    git一些小问题解决 Git撤销git commit 但是未git push的修改 远程删除分支 远程创建仓库 直...

  • git版本控制

    Git解决Push rejected: Push to origin/master was rejected1.g...

  • git 入门系列(一)

    git学习-commit、push常见问题及解决措施(一) git commit 当本地修改完分支,准备将暂存区的...

  • Authentication failed for 'h

    问题1: 当我push代码到Git时,出现 上面我输入了我的全局用户名和Git的登录密码,然而问题出现 解决方法:...

网友评论

      本文标题:解决 git push 速度慢的问题

      本文链接:https://www.haomeiwen.com/subject/lazdzdtx.html