在某些企業或公家機關中,內部網路需透過 Proxy Server 才能連向外部網路,而許多軟體需要額外的設定才能在 Proxy 下運作。
這篇文章描述如何在 Git Terminal 與 Sourcetree 設定 Proxy 連上 Github。
目錄:
(一) Failed connect to github.com:443; No error
在某些企業或公家機關中,內部網路需透過 Proxy Server 才能連向外部網路,而許多軟體需要額外的設定才能在 Proxy 下運作。
例如,當從 Proxy 連上 Github 時,若沒設定 Proxy Server,會出現下列錯誤:
Failed connect to github.com:443; No error
(二) 解決方法
1. 偵測 Proxy Server
首先要先知道主機的 Proxy Server 是的 IP 與 Port,您可以直接詢問網路管理員,或透過下列方式:
Chrome:
# 設定 -> 變更 proxy 設定 -> 連線 -> LAN 設定 -> Proxy 伺服器
IE:
# 工具 -> 網路選項 -> 連線 -> LAN 設定 -> Proxy 伺服器
2. 設定 git config (Sourcetree)
我目前使用的 Git Client 是 Atlassian 的 Sourcetree。
在 Sourcetree 中設定 Proxy 的方式如下:
# 設定 -> Network -> Use custom proxy settings
# 填入剛剛查到的 Server 與 Port
# 把 "Add proxy server configuration to Git" 打勾
3. 設定 git config (git terminal)
如果您不是用 Sourcetree 的話,請在 Git Terminal 用 git config
編輯 http.proxy key
加入 Proxy Server 設定:
git config --global http.proxy http[s]://userName:password@proxyaddress:port
詳細步驟請參考這一篇討論。