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

相关推荐
Unity粉末状在校生7 小时前
Git解决fatal: Could not read from remote repository.的问题
git
少年攻城狮7 小时前
Obsidian系列---【如何使用obsidian同步到git?】
git
do better myself10 小时前
网站源码如何部署和加入GIT仓库的
git
爱学英语的程序员12 小时前
Git 提交 LF will be replaced by CRLF the next time Git touches it 报错
git
qq_3391911413 小时前
服务器git pull每次都要输入密码,linux 设置git登录,linux设置git只输入一次账户密码
git
一颗小行星!19 小时前
快速理解 Git submodule
git
A-Jie-Y21 小时前
Git基础-核心概念与常用命令
git
夜珀1 天前
Git基础修炼手册:在AtomGit上玩转版本控制
git
golang学习记1 天前
Zed IDE官宣新招:Git Graph 正式支持!
ide·git
要记得喝水1 天前
适用于 Git Bash 的脚本,批量提交和推送多个仓库的修改
git·elasticsearch·bash