repo init出错 问题解决方法

在国内repo init在执行时会报类似如下的错误:

fatal: Cannot get https://gerrit.googlesource.c...
fatal: error [Errno 110] Connection timed out
这个是由于repo init会去获取googlesource上获取最新的repo.但是这个site在国内是无法访问的。

解决方法如下:
利用国内的镜像站https://mirrors.tuna.tsinghua...

下载

curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo 

为了方便可以将其拷贝到你的PATH里。

更新

repo的运行过程中会尝试访问官方的git源更新自己,如果想使用tuna的镜像源进行更新,可以将如下内容复制到你的~/.bashrc

export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo' 

并重启终端查看REPO_URL是否生效。