Skip to content

Instantly share code, notes, and snippets.

@imathis
Created August 17, 2015 03:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imathis/7c1ac0a66939caa25b4e to your computer and use it in GitHub Desktop.
Save imathis/7c1ac0a66939caa25b4e to your computer and use it in GitHub Desktop.
Clone all repositories under a user or organization
#!/usr/bin/ruby
require 'open-uri'
require 'json'
user = 'imathis'
repos = open("https://api.github.com/users/#{user}/repos") { |f|
JSON.parse(f.readlines.join)
}
FileUtils.mkdir_p('~/workspace/#{user}')
repos.each do |repo|
`git clone #{repo['ssh_url']} ~/workspace/#{user}/#{repo['name']}`
puts "cloned #{repo['name']} to ~/workspace/#{user}/#{repo['name']}"
end
@imathis
Copy link
Author

imathis commented Aug 17, 2015

This does no error checking and it's not particularly clever, but it uses GitHub's API to clone every repository under a user or organization. I use this to set up my new machines, fetching all my projects down at once.

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