编辑 ~/tydxbc/repo,把 REPO_URL 一行替换成下面的:
REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'建立一个名为android_source的工作目录:
felix@ubuntu:~$ mkdir android_source felix@ubuntu:~$ cd android_source/设置git邮箱和用户名:
felix@ubuntu:~$ git config --global user.email "这里填你的邮箱"felix@ubuntu:~$ git config --global user.name "这里填你的用户名"如果没有设置git用户邮箱和用户名,运行下面初始化仓库的命令是会出现下面的错误提示:
Run git config --global user.email "you@example.com" git config --global user.name "Your Name"to set your account's default identity.Omit --global to set the identity only in this repository.fatal: unable to auto-detect email address (got 'felix@ubuntu.(none)')初始化仓库(此处使用android-5.1.1_r25,看你需要什么源码版本):
felix@ubuntu:~/android_source$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r62出现下面画面表示前面的步骤成功(也有可能步骤没错,但还是出了问题,下面说到):
Get https://gerrit-google.tuna.tsinghua.edu.cn/git-repo/clone.bundleGet https://gerrit-google.tuna.tsinghua.edu.cn/git-reporemote: Counting objects: 1, doneremote: Finding sources: 100% (80/80)remote: Total 80 (delta 30), reused 80 (delta 30)Unpacking objects: 100% (80/80), done.From https://gerrit-google.tuna.tsinghua.edu.cn/git-repo 58f85f9..6284568 master -> origin/master 203153e..39252ba stable -> origin/stable * [new tag] v1.12.34 -> v1.12.34Get https://aosp.tuna.tsinghua.edu.cn/platform/manifest...... * [new tag] android-5.1.1_r20 -> android-5.1.1_r20 * [new tag] android-5.1.1_r22 -> android-5.1.1_r22 * [new tag] android-5.1.1_r23 -> android-5.1.1_r23 * [new tag] android-5.1.1_r24 -> android-5.1.1_r24 * [new tag] android-5.1.1_r25 -> android-5.1.1_r25 * [new tag] android-5.1.1_r26 -> android-5.1.1_r26......如果出现下面的提示,导致初始化失败:
fatal: Cannot get https://gerrit-google.tuna.tsinghua.edu.cn/git-repo/clone.bundlefatal: error [Errno 101] Network is unreachable这大概是网络的原因,把上面那条初始化命令再跑几次试一下,就成功了。就我的经验而言,有时候没有出现上面的网络问题,有时候把repo init初始化命令再跑一遍就行,还试过跑几次才成功的
同步源码树:
felix@ubuntu:~/android_source$ repo sync同步源码树过程中可能会不断出现下面提示:
curl: (22) The requested URL returned error: 404 Not Found不必理会,只要同步过程没有停止就是没有问题的。
如果同步的过程中断了,例如不小心把命令行窗口关闭了,再次执行repo sync命令即可。如果在代码同步完成前重启了机器,就需要先把repo添加到环境变量,再执行repo sync命令。
漫长的等待之后(看网速,我用了半天),同步完成会出现:
......Syncing work tree: 100% (486/486), done.