LoginSignup
9
11

More than 1 year has passed since last update.

【エラー】プロキシ環境内でのGit コマンド使用【備忘録】

Last updated at Posted at 2022-09-05

はじめに

会社内などのプロキシ環境内から Git コマンドを使用する機会があったのですが、
「fatal: unable to access 'https://github.com/hoge/hoge.git/': Failed to connect to github.com port 443 after 21110 ms: Timed out
というエラーが発生しました。

解説策を備忘録として記録します:pencil2:

解決方法

https://maku77.github.io/git/settings/proxy.html
↑こちらの記事を参考に解決しました。
※以下、上記の記事を引用

次のようにプロキシサーバーのアドレス(とポート番号)を設定すると、エラーが解消されました。

プロキシサーバーのアドレス(とポート番号)を設定

$ git config --global http.proxy http://proxy.example.com:8080

# "proxy.examle.com:8080"の部分は適宜変えてくださいね!

設定されているか確認

$ git config --global --list
...
http.proxy=http://proxy.examle.com:8080
$ cat ~/.gitconfig
...
[http]
	proxy = http://proxy.examle.com:8080

「 http.proxy=http://proxy.examle.com:8080 」が設定されていればOK :point_up:

補足

Git のプロキシ設定を削除するには

$ git config --global --unset http.proxy

プロキシ設定を削除するには、git config --unset コマンドを使用すればいいみたい:point_up::point_up:

Git のプロキシ設定を一時的に無効にするには

$ git -c http.proxy= pull

リモートワークなどで、一時的にプロキシ設定を無視して git コマンドを使用したい場合は、
-c オプションで http.proxy 設定を空に指定すればいいみたいです:point_up::point_up:

※http.proxy= の後ろには空であることを示すスペースがあることに注意
※明示的に http.proxy="" としてもOK

まとめ

以上、Gitコマンド実行時のプロキシエラーの解消方法でした:bow:

9
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
11