Git がプロキシを使用する方法

  • Git のプロキシを設定する

1 つまたは 2 つの方法

  • --golbal: すべてのリポジトリのプロキシを設定します (グローバル プロキシを設定します)。
  • 追加されていません--golbal: 指定されたウェアハウス ディレクトリのプロキシを設定します (ローカル プロキシを設定します)。

2. 実施方法

2.1. グローバルプロキシの設定

  • http://127.0.0.1:7890静的ホスト: VPN のポートに注意してください。
  • http://2 つのプロキシ モードがありますhttps://(訪問した Web サイトに応じてhttp、またはhttpsどちらの方法を選択するかを決定します)。
# git config --global http.proxy http://proxyUsername:[email protected]:port
# git config --global https.proxy http://proxyUsername:[email protected]:port
# git config --global 协议.proxy 协议://ip地址:端口号
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

2.2. 特定の Web サイトのみにプロキシを設定する: たとえばGithub

  • http.の間にproxyプロキシが必要な Web サイトの URL を挿入します。
#只对github.com
git config --global http.https://github.com.proxy http://127.0.0.1:7890
git config --global http.https://github.com.proxy socks5://127.0.0.1:7891

#取消代理
git config --global --unset http.https://github.com.proxy

2.3. 指定したリポジトリで使用するプロキシを設定する

# $ git clone https://仓库地址 --config "https.proxy=proxyHost:proxyPort"
git clone https://github.com/skywind3000/asyncrun.vim.git --config https.proxy=https://127.0.0.1:7890

2.4. プロキシが成功したかどうかを確認する

git config --global --get http.proxy
git config --global --get https.proxy

おすすめ

転載: blog.csdn.net/weixin_43476776/article/details/127453208