Git是Linux Torvalds為了協助管理Linux核心開發而開發的一個開放源碼的公布式版本控制軟體。在Git版本控制系統中,每一個工作目錄都包含一個完整倉庫,它們支援離線工作。
Android是由kernel、Dalvik、Bionic、build等多個Git項目組成的,所以Android項目編寫了一個名為Repo的Python指令碼來統一管理這些項目的倉庫。
(1)安裝Git
$ sudo apt-get install git-core curl
(2)安裝Repo
$ mkdir ~/bin
把~/bin添加到PATH變數
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod +x ~/bin/repo
(3)初始化版本庫
$ mkdir ~/android
$ cd ~/android
# 擷取最新的源碼庫
$ repo init -u git://android.git.kernel.org/platfrom/manifest.git
#擷取某個branch的源碼
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
#只需要擷取某一個project的源碼
$ git clone git://android.git.kernel.org/kernel/common.git
(4)同步版本庫
#同步幾個項目
$ repo sync project1 project2 ……
#同步單個目錄
$ cd project
$ git pull
(5)擷取android linux kernel源碼
$ cd ~/android
$ git clone git://android.git.kernel.org/kernel/common.git android-kernel
$ cd android-kernel
$ git checkout --track -b android-2.6.32 origin/android-2.6.32