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

相关推荐
小钟不想敲代码7 小时前
GitFlow
git·gitflow
云和数据.ChenGuang13 小时前
git commit复合指令
大数据·git·elasticsearch
-拟墨画扇-17 小时前
Git | 文件提交操作
git·gitee·github·gitcode
CoderJia程序员甲17 小时前
GitHub 热榜项目 - 日榜(2025-12-25)
git·ai·开源·llm·github
-拟墨画扇-18 小时前
Git | 文件修改操作
大数据·git·gitee·github·gitcode
-拟墨画扇-18 小时前
Git | 版本控制操作
大数据·git·gitee·github
GA66666620 小时前
PowerWiki:基于 Git 的知识管理系统
git
-拟墨画扇-21 小时前
Git | 状态查看操作
git·gitee·github·gitcode
码灵21 小时前
Git相关软件常用操作
git
-拟墨画扇-21 小时前
Git | 简介与安装
大数据·git·elasticsearch