Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /www/wwwroot/blog.somekey.cn/usr/themes/Joe/public/tencent_protect.php on line 40

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/wwwroot/blog.somekey.cn/usr/themes/Joe/public/tencent_protect.php on line 40
git如何设置代理 - 桃子🍑关键词

git如何设置代理

admin
2023-06-11 / 0 评论 / 153 阅读 / 正在检测是否收录...

临时设置

打开 Git Bash,使用命令临时设定:

socks代理
git config --global http.proxy 'socks5:socks5端口号'
git config --global https.proxy 'socks5://127.0.0.1:10809'
http代理
git config --global http.proxy 'IP:PORT'
git config --global https.proxy 'https://127.0.0.1:10809'

永久设置

若想要设置代理永久生效,则可以把它写入 .gitconfig 文件中。使用 vi 打开 .gitconfig 文件:vi ~/.gitconfig写入下列配置(建议在最末写入):

[http]
proxy = socks5://127.0.0.1:socks5端口号
proxy = http://127.0.0.1:http端口号
[https]
proxy = socks5://127.0.0.1:socks5端口号
proxy = https://127.0.0.1:http端口号

修改后重启 git ,使配置生效:

git config -l --global

查看当前代理

git config -l

可以看到自己所配置的端口信息,则说明配置成功。

取消代理

git config --global --unset http.proxy
git config --global --unset https.proxy
0

评论

博主关闭了所有页面的评论