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代理。

相关推荐
vistaup8 小时前
windows git 更新当前目录下所有的文件(非递归)
windows·git
王码码20358 小时前
Flutter for OpenHarmony:Flutter 三方库 algoliasearch 毫秒级云端搜索体验(云原生搜索引擎)
android·前端·git·flutter·搜索引擎·云原生·harmonyos
Irene199112 小时前
Git 命令汇总表(基于一次完整的 Git 实战经验整理,涵盖从安装配置到日常开发、问题排查的所有常用命令)
git·常用命令
q54314708713 小时前
Redis Desktop Manager(Redis可视化工具)安装及使用详细教程
redis·git·bootstrap
素雨迁喜14 小时前
Linux平台下git工具的使用
linux·运维·git
Irene199116 小时前
Windows环境,VS Code 中 Git 配置指南
git·基础配置
Yang-Never17 小时前
AI Code -> Windows电脑安装Claude
开发语言·windows·git
Irene199117 小时前
2026 前端开发 Windows 安装 Git 配置指南(有实际安装过程参考:适配版本 the latest 2.53.0(2) x64 )
前端·windows·git
早起的年轻人18 小时前
告别Git仓库臃肿:一招解决Maven target目录误提交问题
java·git·maven
悠然大月季1 天前
git 怎么导出提交历史,文件是乱码
git·git导出历史记录·git导出历史乱码