The size of the latest AOSP source code is rather large (around 30-35 Gb for the .repo directory and another 15 Gb or so for the working directory). Is there a way to download only a snapshot of the latest version of the source code (official marshmallow release) without the entire repo history? That would save me a lot in bandwidth and storage.
3 Answers
You can specify --depth 1
to git clone command. It will only get the latest snapshot.

- 32,635
- 12
- 70
- 99
-
5Thank you, this works great when using git on individual projects. It looks like to apply the depth for all projects within AOSP all at once, it can be done with the following repo command: `repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b android-6.0.0_r1` prior to running `repo sync` – Phil Oct 11 '15 at 13:45
-
2When using the commands from my comment above, I ended up with a 6.1 Gb .repo directory for the marshmallow branch. – Phil Oct 11 '15 at 13:47
-
Can I download the older commits later? – Suici Doga May 10 '16 at 14:36
-
I downloaded it and it took about 2 hours to download (16mbs) – Suici Doga May 11 '16 at 05:21
-
I also want to know how to download the commits history later if needed – Biao Cao Jun 28 '20 at 03:48
Step to download android source code(AOSP) in Ubuntu
First create one folder like "aosp-m" to copy AOSP code in your machine.
Open terminal(Ctrl+Alt+T) and change your Dir to latest created Dir let say "aosp-m"
After that Run the following command in terminal :- git clone git://gitz01/cm/download/android/manifest if this link not work then try this one repo init -u https://android.googlesource.com/platform/manifest
Run Following command in terminal one by one git config --global user.name "Your Name" git config --global user.email "you@example.com"
then run following command for repo init repo init -u git://gitz01/cm/download/android/manifest -b master -m identifiedmanifest.xml if this link not work then try this one repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b identifiedmanifest.xml here you can replace identifiedmanifest.xml to your desired AOSP source code , Let Say "android-6.0.1_r10.xml" marshmellow.
and in the last run "repo sync" command. This command start downloading your desired AOSP code in your machine. This opertation take more than 1 hours(depending on your internet connection speed) to download source code. Thats it... Happy Coding.......

- 2,262
- 1
- 19
- 19
Since git
version 2.19 (released in 2018), we can utilize git
's --partial-clone
flag via the repo
tool like the following:
repo init -u https://android.googlesource.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M
For readers of this question and answer in 2020, be warned that the AOSP repositories have gotten bigger and the above command still results in around 73 gigabytes of source code and related files.

- 1,128
- 2
- 13
- 22