hincky的主页 hincky的主页
  • 学习笔记

    • Vue笔记
    • Vuepress
    • nginx
  • 语言类

    • java
    • go
    • python
    • 设计模式
  • 框架类

    • Spring
    • Spring Security
    • Mybatis
  • 容器技术

    • docker
    • k8s
    • helm
    • prometheus
    • grafana
    • jenkins
  • 命令集合

    • linux命令
    • docker命令
    • git命令
    • vim命令
    • k8s命令
  • 数据库

    • sql
    • mysql
  • 协议

    • 网络模型
    • http/1.1
    • WebSocket
    • http/2
    • TLS/SSL
    • tcp
    • IP
    • tcpdump抓包命令
    • wireshark抓包工具
  • 通用

    • Git
  • 技术分享

    • git push/pull总是超时怎么办
    • idea debug技巧
    • postman使用
    • 问题总结
    • idea使用技巧
  • Oauth2

    • Oauth2原理
  • 项目列表

    • redis项目
    • 微服务项目
  • 分类
  • 标签
  • 归档
  • 随笔
GitHub (opens new window)

Hincky

当有趣的人,做想做的事
  • 学习笔记

    • Vue笔记
    • Vuepress
    • nginx
  • 语言类

    • java
    • go
    • python
    • 设计模式
  • 框架类

    • Spring
    • Spring Security
    • Mybatis
  • 容器技术

    • docker
    • k8s
    • helm
    • prometheus
    • grafana
    • jenkins
  • 命令集合

    • linux命令
    • docker命令
    • git命令
    • vim命令
    • k8s命令
  • 数据库

    • sql
    • mysql
  • 协议

    • 网络模型
    • http/1.1
    • WebSocket
    • http/2
    • TLS/SSL
    • tcp
    • IP
    • tcpdump抓包命令
    • wireshark抓包工具
  • 通用

    • Git
  • 技术分享

    • git push/pull总是超时怎么办
    • idea debug技巧
    • postman使用
    • 问题总结
    • idea使用技巧
  • Oauth2

    • Oauth2原理
  • 项目列表

    • redis项目
    • 微服务项目
  • 分类
  • 标签
  • 归档
  • 随笔
GitHub (opens new window)
  • 数据库

  • 网络协议以及抓包工具

  • Git笔记

  • 技术分享

    • git push/pull总是超时怎么办
      • 给github设置http/ssh代理
        • macOS
        • Windows
      • git加速
    • idea debug技巧
      • debug相关的快捷键
      • 行断点
      • 详细断点(源断点)
      • 方法断点
      • 异常断点 | 全局捕获
      • 字段断点 | 读写监控调试方式
      • 断点条件
      • 打印堆栈信息
      • 表达式解析
      • 避免误操作资源
    • postman使用
      • 什么是接口(API)
      • api应用
      • api 返回格式
      • api 协议
    • 问题总结
    • idea使用技巧
      • 快速补全
    • Windows快捷键
      • 管理员身份打开cmd
      • 快速打开系统环境变量
    • 科学上网
      • 介绍
      • clash
      • gatern
        • 导入订阅信息到clash
      • google验证
        • 问题排查
  • Oauth2

  • 计算机相关技术
  • 技术分享
hincky
2022-09-29
目录

git push/pull总是超时怎么办

# git push/pull总是超时怎么办

Q:

相信各位经常在git pull/push遇到代码同步远程仓库的问题,尤其是当仓库在github的时候。连接超时的问题总是困扰着大家。很多伙伴即使已经使用了科学上网的方式之后,依然频出超时问题

A: 集思广益之后,总结出以下几种解决方案:

参考方案与链接

  1. macOS 给 Git(Github) 设置代理(HTTP/SSH) (opens new window)
  2. git加速
  3. Git加速必经之路 (opens new window)
  4. Github加速的10种方式 (opens new window)

# 给github设置http/ssh代理

# macOS

  • http形式
# http
git config --global http.proxy "http://127.0.0.1:8080"
git config --global https.proxy "http://127.0.0.1:8080"
# socks5
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
# 取消设置
git config --global --unset http.proxy
git config --global --unset https.proxy
1
2
3
4
5
6
7
8
9
  • ssh形式 修改 ~/.ssh/config 文件(不存在则新建):
# 必须是 github.com
Host github.com
   HostName github.com
   User git
   # 走 HTTP 代理
   # ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080
   # 走 socks5 代理(如 Shadowsocks)
   # ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
1
2
3
4
5
6
7
8

# Windows

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  # 注意修改路径为你的路径
  IdentityFile "C:\Users\luche\.ssh\id_rsa"
  TCPKeepAlive yes

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  # 注意修改路径为你的路径
  IdentityFile "C:\Users\luche\.ssh\id_rsa"
  TCPKeepAlive yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

使用Clash

# github
Host *github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa
  ProxyCommand connect -S 127.0.0.1:7890 -a none %h %p
1
2
3
4
5

# git加速

  1. 访问这里 (opens new window),获取CDNip和域名 eg: 140.82.114.4 http://github.com
  2. 再访问这里 (opens new window),获取CDNip和域名 eg: 140.82.114.4 http://github.com
  3. 管理员身份修改本地host文件,映射上面查找到的IP Windows:c:Windows-System32-drivers-etc-hosts 在最后添加:
151.101.1.194		github.global.ssl.fastly.net
151.101.65.194		github.global.ssl.fastly.net
151.101.129.194		github.global.ssl.fastly.net
151.101.193.194		github.global.ssl.fastly.net

140.82.113.4 		github.com
1
2
3
4
5
6
  1. 刷新DNS缓存

Windows

ipconfig /flushdns
1

liunx

systemctl restart network
1
编辑 (opens new window)
#技术分享#git
Git工具-重置揭密
idea debug技巧

← Git工具-重置揭密 idea debug技巧→

最近更新
01
人生前期重要的能力
05-17
02
防火墙命令
04-11
03
docker-compose部署mysql主从集群
03-22
更多文章>
Theme by Vdoing | Copyright © 2022-2023 Hincky | MIT License | 粤ICP备2022120427号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式