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

相关推荐
打不了嗝 ᥬ᭄14 小时前
Git 原理与使用
git·gitee
m0_6146190616 小时前
花了一下午学 Git,整理了一份学习笔记
笔记·git·学习
AGV算法笔记17 小时前
解决Git> git add -A -- fatal: CRLF would be replaced by LF in Test/Test.cpp
git
Dontla19 小时前
VSCode插件Git Graph介绍(Git可视化管理分支、可视化Git)
ide·git·vscode
Echoo华地19 小时前
用git diff快速比较文件夹差异并生成报告
linux·git·unix·repository·diff·branch
勤劳打代码20 小时前
防微杜渐 —— 为什么一次 Sync 会变成一次 merge?
git·团队管理
dyxal21 小时前
Windows 下 Git 离线安装与 VS Code 便携版集成完全指南
windows·git·elasticsearch
K3v21 小时前
【git】自动化合并推送脚本
git·自动化
鹓于21 小时前
Android APK开发到发布全流程指南
git·github
花哥码天下1 天前
Git 多远程仓库管理
git