Linux – Download multiple branches to the same directory using repo


repo is a python script that manages cyanogenmod source code download.

to download cm-10.1 branch, repo command is,

cd ~/cm-10.1

repo init -u -b cm-10.1

cd ~/cm-11

then we can use –reference option to download cm-11 source code like

repo init –reference=~/cm-10.1 -u -b cm-11.0

but, that downloads the delta data into cm-11 directory.

I want to download all the cyanogenmod branches in single directory and build as required. How can i do this?

Best Answer

Since you are using the same URL for all the branches, you can download them to a single folder, and still they are kept separate.

You can download multiple branches of project files into a single .repo folder in a single working directory. This saves disk space and eliminates hurdles like path sensitive repo --reference , inability to use multiple references.

To download all branches into same .repo folder, do

repo init -u -b cm-10.1
repo sync
repo init -b cm-10.2
repo sync
repo init -b cm-11.0
repo sync

and the list goes..
This downloads all the branches to the single .repo folder in a single working directory. When initializing a second branch, we donot provide the -u url option because we are reusing a different branch from local repo.

After repo sync the working directory contains the last initialized branch and this is completely harmless. We are only concerned about the working directory, not the contents of .repo folder. The branches still stay separate.

You may occasionally use repo forall -c git gc to pack all loose objects into pack files.

Related Question