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

相关推荐
Leo⁵6 小时前
基于 Git 的 Obsidian 笔记同步
笔记·git
Qres8219 小时前
Git基础命令学习笔记
笔记·git·学习
REDcker10 小时前
Git分支与版本管理实践
git
Goodbye15 小时前
Git 开发必备性能
git
Wils0nEdwards15 小时前
Windows本地 git 版本管理
windows·git·elasticsearch
Niliuershangba16 小时前
ChestnutCMS 栗子内容管理系统:从入门到模板开发实战
java·git·开源·gitlab·github·开源软件·gitcode
专注VB编程开发20年16 小时前
安桌15系统文件直接存到其他目录要权限吗?/storage/emulated/0/Downloa
git
解道Jdon18 小时前
从Go转向Rust迁移指南:靠自觉 vs. 靠编译器
ide·windows·git·svn·eclipse·github·visual studio
霸道流氓气质20 小时前
Git 三方合并策略详解
git
Cry丶20 小时前
GitHub 开源项目 PR 提交流程:从 Fork 到 CLA 签署
git·github·开源贡献·pull request·cla