Skip to content

Instantly share code, notes, and snippets.

@DanyC97
Created April 8, 2016 08:24
Show Gist options
  • Save DanyC97/c3ea496a27ad01d755b75bed851eb752 to your computer and use it in GitHub Desktop.
Save DanyC97/c3ea496a27ad01d755b75bed851eb752 to your computer and use it in GitHub Desktop.
To clone all repos from your organisation, try the following one-liner:
ORG=company; curl "https://api.github.com/orgs/$ORG/repos?per_page=1000" | grep -o 'git@[^"]*' | xargs -L1 git clone
For user repos, try:
USER=foo; curl "https://api.github.com/users/$USER/repos?per_page=1000" | grep -o 'git@[^"]*' | xargs -L1 git clone
If you need to clone the private repos, you've to insert your API key. Also check for hub tool which could probably help you with that.
Hints:
- To increase speed, set number of parallel processes by specifying -P parameter for xargs (-P4 = 4 processes).
- If you need to raise the GitHub limits, try authenticating by specifying your API key.
- Add --recursive to recurse into the registered submodules, and update any nested submodules within.
@DanyC97
Copy link
Author

DanyC97 commented Apr 18, 2016

also try this:

  • Create an API token by going to Account Settings -> Applications
  • Make a call to: http://${GITHUB_BASE_URL}/api/v3/orgs/${ORG_NAME}/repos?access_token=${ACCESS_TOKEN}
  • The response will be a JSON array of objects. Each object will include information about one of the repositories under that Organization. I think in your case, you'll be looking specifically for the ssh_url property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment