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

相关推荐
-拟墨画扇-2 小时前
Git | 分支管理操作
git·gitee·github·gitcode
ModestCoder_2 小时前
Git 版本管理教程
大数据·git·elasticsearch
YMGogre2 小时前
Git 提交信息规范
git
charlie1145141913 小时前
Git团队协作完全入门指南(下)
git
golang学习记5 小时前
Facebook 为什么不用 Git?
git·elasticsearch·facebook
GIS阵地6 小时前
git拉取时报错
大数据·git·elasticsearch
无限进步_8 小时前
C++ Vector 全解析:从使用到深入理解
开发语言·c++·ide·windows·git·github·visual studio
charlee448 小时前
Git使用经验总结9-Git提交关联到Issue
git·issue
-拟墨画扇-9 小时前
Git | Bug分支操作
git·gitee·github·bug·gitcode
-拟墨画扇-11 小时前
Git | Feature分支操作
git·gitee·github·gitcode