Git 设置代理

Git 传输分两种协议,SSH和 http(s),设置代理也需要分两种。

http(s) 代理

Command Line

使用 命令行 模式,可以在Powershell中使用以下命令设置代理:

bash 复制代码
$env:http_proxy="http://127.0.0.1:7890"
$env:https_proxy="http://127.0.0.1:7890"

TortoiseGit

SourceTree

SSH 代理

在目录 【C:\Users\用户名\.ssh】下添加一个 config 文件,并在文件中添加以下配置

bash 复制代码
Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:/Users/[用户名]/.ssh/id_rsa"
  ProxyCommand connect -S 127.0.0.1:7890 -a none %h %p
  TCPKeepAlive yes

PS

虽然使用SSH,但是因为Git拉取 子模块,LFS时使用的是http传输,所以在使用ssh克隆时,如果仓库中有子模块或者LFS,也需要同时设置http代理。

相关推荐
noravinsc16 小时前
关于Git Flow
git
蜜獾云17 小时前
在Git中配置用户名和密码
git
scx_link19 小时前
通过git bash在本地创建分支,并推送到远程仓库中
开发语言·git·bash
南大白20 小时前
IntelliJ IDEA 运行时的 JVM 本地内存溢出崩溃
git
码农小旋风21 小时前
Claude Code 基础用法大全:对话、分析、修改、测试、Git 和工作流
人工智能·git·chatgpt·claude
南大白21 小时前
Git 撤回提交完整方案
git
像风一样的男人@1 天前
python --实现代理服务器
git·ui
sbjdhjd1 天前
从零搭建企业级 CI/CD(下):Jenkins+GitLab+Harbor 全链路实战指南
git·servlet·ci/cd·云原生·云计算·gitlab·jenkins
码云数智-大飞1 天前
Go Channel 详解:并发通信的正确姿势
前端·数据库·git
OsDepK1 天前
OSMDE手机AI编程,一键Git
git·ai编程