git 代理設定,以及日常問題解決思路。
不知道是否有同學遇到如下的問題:
git clone https://github.com/istester/ido.git #一個git倉庫。
确收到如下報錯:
Cloning into 'hosts'...
fatal: unable to access 'https://github.com/racaljk/hosts.git/': Failed to connect to 192.168.1.22 port 8080: Connection refused
如上,明明clone的github倉庫代碼,為何會收到無法連結内網的錯誤呢 ?
網上找了很多文章,沒啥直接的答案。
解決思路:
猜測是git的配置問題,先看看git的所有配置資訊
git config --list
可以顯示所有的配置資訊。
[Ido-Air:gitHome idoxu$ git config --list
credential.helper=osxkeychain
color.ui=true
user.name=Ido
http.proxy=http://192.168.1.22:8080/
https.proxy=http://192.168.1.22:8080/
core.excludesfile=/Users/idoxu/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
如上,确實有http://192.168.1.22:8080/的配置資訊,問題定位到。
那麼,如何去掉配置呢 ?
原來是設定了代理。
去掉代理即可。
git config --global --unset http.proxy
git config --global --unset https.proxy
如上,搞定,再次 git clone ,代碼可正常down下來。
延伸,既然涉及到了git的代理,那麼作為好奇心,以及強烈學習欲望的tester ,必須得了解下如何設定代理。
git 代理設定方法:
git config --global http.proxy http://192.168.1.22:8080/
git config --global https.proxy https://192.168.1.22:8080/
如果需要使用者名和密碼
git config –global http.proxy http://user:[email protected]:8080
git config –global http.proxy https://user:[email protected]:8080
》》我是IDO老徐,從業十年的IT老鳥,測試職業分享者;文章如未注明轉載,均屬原創 。
歡迎各同行交流探讨,我的個人部落格isTester.com