git


Clone all repositories you have access to over ssh


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

The above command will connect to the git server (git.bytefreaks.net) that is using  gitolite and get a list of all the repositories you have access to using ssh [email protected] info

The command should return a list similar to this:

hello bytefreaks, this is git@git running gitolite3 v3.5.3.1-1-gf8776f5 on git 1.7.1

 R W	Repo1
 R W	Repo2
 R W	Repo3
 R  	Repo4

From the results, we remove the first 3 lines as they contain no useful information to cloning all the repositories. From the rest of the lines, where each line contains the information for a repository we have access to, we keep the third column only as it is the one that holds the repository name as it is stored on the server.

On the last stage of the pipe we have a list of the names of the repositories, using xargs, we assign each repository name to the special variable {} and processing one result at a time we clone the git repository to the current directory under the folder that is named as the repository.


How to list all available repositories on a Git server via ssh 12

ssh [email protected] info

The above ssh call will connect to a Git hosting server that has gitolite installed and will return the list of repositories that are available to your account along with the access rights of each.

Note: This command should work even if remote login via ssh is blocked on the server.

The command should return a list similar to this:

hello bytefreaks, this is git@git running gitolite3 v3.5.3.1-1-gf8776f5 on git 1.7.1

 R W	Repo1
 R W	Repo2
 R W	Repo3
 R  	Repo4

The first column in the results is the read flag, the second the write flag and the third column is the name of the repository.

In order to clone (get a local copy) a repository from the above list (for the example lets use Repo1) you have to issue the following command


git clone ssh://[email protected]/Repo1

To clone all of the repositories in the current directory with one command, as it is shown in this guide, issue the following command:


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