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

相关推荐
我家媳妇儿萌哒哒12 小时前
git:无法推送refs到远端。您可以试着运行“拉取”功能,整合您的更改。
git
驯龙高手_追风15 小时前
Gitlab本地服务器搭建及配置-详细教程
git·github
czhc114007566315 小时前
6.11:halcon,Sqlserver;项目sql连接;git
git·sql·sqlserver
炸炸鱼.16 小时前
Git+Jenkins 基本使用:从入门到实战(知识点大全)
运维·git·jenkins
戴国进18 小时前
git stash 用法详解
git
木雷双雄719 小时前
Git 版本回退操作指南
git
m0_579146651 天前
已被 Git 追踪的本地修改文件如何实现临时忽略
git
糖少主1 天前
WSL中使用Beyond Compare 3/4/5作为difftool
git·wsl·beyond compare·difftool
console.log('npc')1 天前
Git版本管控:git reset \+ git push \-f 原理、实操与避坑指南
git
恋喵大鲤鱼2 天前
git reflog
git·git reflog