notes 笔记notes 笔记
Home
Article
Category
Tag
Timeline
Home
Article
Category
Tag
Timeline
  • build

    • 环境变量
  • browse

    • 2fa
    • sse
    • token
  • database

    • mongodb

      • start
    • mysql

      • curd
      • 安装
      • join
      • 多对多
      • 性能优化
      • 表设计
      • 常见问题
  • docker

    • github-actions

      • local
      • prod
    • docker-compose
    • index
    • podman
  • file

    • 文件下载
    • 原生 node.js下载文件
  • git

    • index
    • multiple-github-accounts
    • auto-commit
    • pat
    • rebase
  • linux

    • grep
    • index
    • ssh
    • vim
    • windows
  • network

    • best-proxy-way
    • git-via-https
    • github-push-fail
  • nginx

    • acme.sh
    • cache
    • https
    • index
    • safe
  • node

    • fnm
    • tool
  • obsidian

    • ish
    • start
  • react

    • index
    • set-state
  • summary

    • index
  • vue

    • index
    • typescript
  • libs
  • open-source
  • 症状
  • 可能的原因和解决方法
    • 机场模式选择不对,可以试试 tun 模式
    • 机场服务商把 ssh 协议 or 22 端口封了,需要设置下 git via https
    • git config proxy
    • 命令行 proxy
    • 仓库目录下执行 git config --local -e ,弹出文件编辑,git@github.com:改为 https://github.com/
  • Reference

症状

本地浏览器可以访问,但是 push 代码超时。
阿里云服务器也无法 clone 代码。

proxy 用的小猫咪,异常信息:

git push origin main
Connection closed by 127.0.0.1 port 7890
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

可能的原因和解决方法

机场模式选择不对,可以试试 tun 模式

机场服务商把 ssh 协议 or 22 端口封了,需要设置下 git via https

ssh config 里加上

Host github.com
HostName ssh.github.com
Port 443
User git

GitHub Docs using-ssh-over-the-https-port

git config proxy

浏览器连 github 是走 https 连接, push 是走 ssh git 本地代理设置好就可以

命令行 proxy

proxy='export https_proxy=http://127.0.0.1:7890;export http_proxy=http://127.0.0.1:7890;export all_proxy=socks5://127.0.0.1:7890'

unproxy='unset https_proxy http_proxy all_proxy'

仓库目录下执行 git config --local -e ,弹出文件编辑,git@github.com:改为 https://github.com/

Reference

  • v2ex-大家 github 还能 push 代码吗?
最近更新:: 2025/10/19 23:44
Contributors: qyhever
Prev
git-via-https