First of all, you need to have Ubuntu setup (for Windows users, see https://forum.hovatek.com/thread-1004.html )
To install Repo, Launch the Terminal (Ctrl+Alt+T)
1. Make sure you have a bin/ directory in your home directory and that it is included in your path:
$ mkdir ~/bin
2. Download the Repo tool and ensure that it is executable:
$ sudo apt-get install curl
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Initializing a Repo client
After installing Repo, set up your client to access the Android source repository:
1. Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive file system. Give it any name you like:
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
2a. Install Git. After it finishes downloading, you will have Git installed and ready to use.
sudo apt-get install git-core
2b. Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
$ repo init -u https://android.googlesource.com/platform/manifest
For CyanogenMod sources, use
$ repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0
3. When prompted, configure Repo with your real name and Gmail address using
git config --global user.email YourEmail
git config --global user.name YourName
To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.
A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.
Downloading the Android Source Tree
To pull down the Android source tree to your working directory from the repositories as specified in the default manifest, run
$ repo sync
you could also use
repo sync -c -j4
-j instruct repo to download several projects in parallel (making it faster). You should tune the number of jobs repo will launch in paralell with regards of your number of CPU cores, and your bandwidth. -j 16 should be fine for a 8-cores box with a high Internet bandwidth.
-c Ensures repo will only download the revision (branch) that is specified in the manifest, not all the branches that are on the remote server. It will thus save us quite some space, and again it will take less time to download.