Site icon Bytefreaks.net

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

Advertisements

ssh git@git.example.com 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://git@git.example.com/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 git@git.bytefreaks.net info | cut -f 2 | tail -n +3 | xargs -I {} -n 1 git clone ssh://git@git.example.com/{}

This post is also available in: Greek

Exit mobile version