Skip to content

Instantly share code, notes, and snippets.

@lukalafaye
Last active February 4, 2019 04:32
Show Gist options
  • Save lukalafaye/375e09cbb0bb84703d72d4d79b3a1de0 to your computer and use it in GitHub Desktop.
Save lukalafaye/375e09cbb0bb84703d72d4d79b3a1de0 to your computer and use it in GitHub Desktop.
CloneOrg is a simple bash tool used to clone all public and private repositories of a GitHub organization.

CloneOrg

CloneOrg is a simple bash tool used to clone all public and private repositories of a GitHub organization.

Prerequisites

Adding an SSH key to your github account

Downloading the script

$ git clone https://gist.github.com/lukalafaye/375e09cbb0bb84703d72d4d79b3a1de0 

Running the script

$ eval "$(ssh-agent -s)"
# Replace `id_rsa_github` with the SSH key you used on GitHub
ssh-add ~/.ssh/id_rsa_github
cd 375e09cbb0bb84703d72d4d79b3a1de0/
sh cloneorg.sh GITHUBUSERNAME ORGANIZATIONNAME
#!/bin/bash
USERNAME=$1
ORGANIZATION=$2
curl -u $USERNAME -s https://api.github.com/orgs/$ORGANIZATION/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment