Created
August 17, 2015 03:10
-
-
Save imathis/7c1ac0a66939caa25b4e to your computer and use it in GitHub Desktop.
Clone all repositories under a user or organization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
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.