Jens A. Koch

bash script for cloning all repositories of an github organization (

You need to adjust the GITHUB_ORGANIZATION to your needs.

chmod +x


You need to load your SSH KEY,
else you will run into the following error:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly.

Take care!



# The script clones all repositories of an GitHub organization.
# Author: Jens A. Koch
# Date: 24.09.2012

# the github organization to fetch all repositories for

# the git clone cmd used for cloning each repository
# the parameter recursive is used to clone submodules, too.
GIT_CLONE_CMD="git clone --quiet --mirror --recursive "

# fetch repository list via github api
# grep fetches the json object key ssh_url, which contains the ssh url for the repository
REPOLIST=curl --silent${GITHUB_ORGANIZATION}/repos -q | grep "\"ssh_url\"" | awk -F': "' '{print $2}' | sed -e 's/",//g'

# loop over all repository urls and execute clone
for REPO in $REPOLIST; do



2 Responses

  1. Christian Weiske Says:

    This doesn’t work if the organization has so many repositories that they are split onto several pages.

    Github adds a Link header then, e.g. in

  2. jakoch Says:

    When i find the time, i will take a look at this issue.