终端设置代理 Git bash 配置代理的“最”全解决方法

只写http代理, socks5代理没写.

设置代理基本思路 : 配置*的 ip : port ,*会为通过此端口的流量加密混淆 , 将配置端口的命令以某种格式写入到配置文件中实现长久代理

终端设置代理
Git bash 配置代理的“最”全解决方法

测试连接是否成功的命令为 curl -I www.google.com ,看状态码是否为 200

win10 git bash 配置代理

* for windows 将http和socks5代理端口合并了, 都为7890

export http_proxy=http://127.0.0.1:7890;export https_proxy=http://127.0.0.1:7890

配置文件
假设 Git 默认路径为 C:Program FilesGit

  1. 那么配置文件路径为
    C:Program FilesGitetcash.bashrc

    在其中按自己实际的代理方式添加 :
    终端设置代理
Git bash 配置代理的“最”全解决方法

  2. 或者 ~/.gitconfig中添加

    [http]
    	proxy = http://127.0.0.1:7890
    [https]
    	proxy = https://127.0.0.1:7890
    

git配置ssh协议代理

目录 : ~/.ssh/config (没有就自己新建一个,注意没有后缀)

Host github.com
  ProxyCommand "C:Program FilesGitmingw64inconnect.exe" -H 127.0.0.1:7890 %h %p

-H为http代理, -S为socks5代理

npm配置代理

网上一搜基本都是命令行配置 , 我就不写命令行配置方法了

~/.npmrc随便哪一行添加下面的命令

proxy=http://127.0.0.1:7890
https-proxy=http://127.0.0.1:7890

在 vscode 中添加 git bash

在 vscode setting.json末尾添加

//使用Git Bash的配置
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe",
"terminal.integrated.shellArgs.windows": ["--login","-i"]

在 idea 中添加 git bash

终端设置代理
Git bash 配置代理的“最”全解决方法

"C:\Program Files\Git\bin\bash.exe" --login -i

git 美化窗口

这位大佬已经写的很好了

掘金博客

Github

自己美化后的git bash (一直没找到比较好看的字体)

终端设置代理
Git bash 配置代理的“最”全解决方法

终端设置代理
Git bash 配置代理的“最”全解决方法

linux 配置终端代理

推荐使用qv2r*y

archlinux 下载 :

sudo pacman -S v2r*y
sudo pacman -S qv2r*y

配置代理 :

export http_proxy=http://127.0.0.1:7890;export https_proxy=http://127.0.0.1:7890

添加到当前 shell 的配置文件中,
比如 zsh 的配置文件为家目录下的 .zshrc