Clone all repositories of a git server (works for gitolite, bitbucket, gitlab)


Gitolite provides an info command that will list all repositories.

ssh [email protected] info

To clone all repos of gitolite execute:

ssh [email protected] info | cut -f 2 | tail -n +3 | xargs -I {} -n 1 git clone ssh://[email protected]/{}

With this command we use the info command output and process it with cut,tail and execute git clone using xargs.


For bitbucket we are going to use theirs api to donwload repository information. Remeber to change BBA enviroment variable value to your username.

 BBA=BuckbucketUsername; curl --user ${BBA}${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 git clone


To clone all repositories for gitlab we are going to use gitlab api. You will need to generate the api token. The method is very similar to bitbucket, we process the ouput and then send it xargs to clone the repos.

TOKEN="PASTE_YOUR_PRIVATE_TOKEN_HERE"; PREFIX="ssh_url_to_repo"; curl --header "PRIVATE-TOKEN: $TOKEN" | grep -o "\"$PREFIX\":[^ ,]\+" | awk -F ':' '{printf "ssh://"; for (i=2; i<NF; i++) printf $i "/"; print $NF}' | xargs -L1 git clone

Note that gitlab has pagination, we set the page size to 100. If you have more you will need to follow the link header information.