$ sudo apt-get install git-core
$ git config --global user.name "name" $ git config --global user.email "email"
$ cd ~ #进入home目录 $ mkdir bin #建立bin目录用于存放Repo脚本 $ PATH=~/bin:$PATH #将bin目录加入系统路径中 $ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo #curl是一个基于命令 #行的文件传输工具,它支持不少协议。这里利用curl来说repo保存到相应目录下 $ chmod a+x ~/bin/repo
$ mkdir source #用于存放整个项目的源码 $ cd source $ repo init -u https://android.googlesource.com/platform/manifest #init命令用于初始化 #repo并获得近期的版本更新信息。若是你想获取某个非master分支的代码,须要在命令最后加上-b选项。如: $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1 #完成配置后,repo会有以下提示:repo initialized in /home/android,这时在你的机器home目录下会有 #一个.repo目录,用于记录manifrest等信息。
由于google的服务起连接问题,这里能够将上述信息修改成如下内容:android
打开~/bin/repo,并修改此行代码为:git
REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'
而后将命令:api
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
修改成:bash
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1
$ repo sync
以上镜像来自清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/curl