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

相关推荐
高山莫衣4 小时前
git rebase多次触发冲突
大数据·git·elasticsearch
码农藏经阁4 小时前
工作中常用的Git操作命令(一)
git
kobe_OKOK_5 小时前
【团队开发】git 操作流程
git·elasticsearch·团队开发
码农垦荒笔记5 小时前
Git 安装闭坑指南(仅 Windows 环境)
windows·git
CC码码14 小时前
管理你的多个 Git 密钥(多平台多账号)
git·gitlab·github
CC码码14 小时前
管理你的多个 Git 密钥(单平台多账号)
git·gitlab·github
大卫小东(Sheldon)14 小时前
GIM 1.5发布了! 支持Windows系统了
git·ai·rust
flying jiang15 小时前
将大仓库拆分为多个小仓库
git
李boyang10 天前
Git(四):远程操作
git
荻野泽溪10 天前
Git新建分支并同步到远程
git