git無法clone遠程代碼庫及git代理設置


  git作為一個版本管理神器,日常工作中自然也就少不了了;特別是Android開發,github和google是逃不過的了。然而很多時候需要用到git克隆遠程的代碼庫,眾所周知的原因google、android官網都是無法訪問的。那么我們怎么克隆諸如:android.googlesource.com下的庫呢?

  工具:git、vpn代理

  實例:git clone https://android.googlesource.com/platform/frameworks/volley/

D:\AndroidStudioProjects> git clone https://android.googlesource.com/platform/frameworks/volley/
Cloning into 'volley'...
fatal: unable to access 'https://android.googlesource.com/platform/frameworks/volley/': Failed connect to android.googlesource.com:443; No error

  Failed connect to android.googlesource.com:443這很明顯是由於被牆了。那么怎么辦呢?首先想到的是VPN,前提是你需要有一個VPN。

  設置git代理

git config --global http.proxy "localhost:1080"

  再次運行

git clone https://android.googlesource.com/platform/frameworks/volley/

  此時可以看到如下結果

D:\AndroidStudioProjects> git clone https://android.googlesource.com/platform/frameworks/volley/
Cloning into 'volley'...
remote: Counting objects: 81, done
remote: Finding sources: 100% (81/81)
Receiving objects: 100% (2953/2953), 1.16 MiB | 23.00 KiB/s, done.
remote: Total 2953 (delta 263), reused 2953 (delta 263)R/263)
Resolving deltas: 100% (263/263), done.
Checking connectivity... done.

  Android開發,沒有VPN你叫我情何以堪?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM