Skip to content

Instantly share code, notes, and snippets.

@egabancho
Forked from imathis/clone.rb
Created April 7, 2016 19:58
Show Gist options
  • Save egabancho/66bd0b04c4926e826d2ff56e29fc258f to your computer and use it in GitHub Desktop.
Save egabancho/66bd0b04c4926e826d2ff56e29fc258f 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment