GIt需要設(shè)置代理柜候,才能正常訪問github 等網(wǎng)站
設(shè)置如下(可復(fù)制):
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
代理服務(wù)器需要鑒權(quán)配置
git config --global https.proxy https://username:password@proxy.baidu.com:8080
密碼中特殊字符處理
如果密碼中有@等特殊字符搞动,會出錯,
比如git config --global http.proxy http://username:abc@123@proxy.baidu.com:8080
解析時(shí)會從第一個@解析渣刷,提示@123@proxyhk.huawei.com找不到鹦肿,
此時(shí)要對其中的特殊符號進(jìn)行處理,使用百分比編碼(Percent-encoding)對特殊字符進(jìn)行轉(zhuǎn)換辅柴,轉(zhuǎn)換列表如下:
! --> %21? ? ? ?# --> %23? ? ?$ --> %24? ? ?& --> %26? ? ?' --> %27
( --> %28? ? ? ?) --> %29? ? ? * --> %2A? ? ?+ --> %2B? ? ?, --> %2C?
/ --> %2F? ? ? : --> %3A? ? ? ; --> %3B? ? ? = --> %3D? ? ?? --> %3F?
@ --> %40? ? ?[ --> %5B? ? ?] --> %5D
參考資料:http://stackoverflow.com/questions/6172719/escape-character-in-git-proxy-password?
如以上示例中的配置箩溃,可以替換為:
git config --global http.proxy http://username:abc%40123@proxy.baidu.com:8080
Git代理取消
git config --global --unset http.proxy
git config --global --unset https.proxy
Linux Git常見錯誤
1瞭吃、克隆失敗,提示:server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
解決方法:
export GIT_SSL_NO_VERIFY=1
git config --global http.sslverify false
2涣旨、提示:GnuTLS recv error (-9): A TLS packet with unexpected length was received
error: RPC failed; result=56
解決方法:配置以下三條命令
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
3歪架、以上命令還不生效,則祭出大殺器此問題為git中依賴gnutls的bug霹陡,需要對將git中的gnutls強(qiáng)制替換為openssl和蚪,重新編譯即可
解決方案:http://askubuntu.com/questions/186847/error-gnutls-handshake-failed-when-connecting-to-https-servers/187199#187199