Skip to content

Instantly share code, notes, and snippets.

@akira345
Created May 20, 2017 09:09
Show Gist options
  • Save akira345/54e876c9b7c80f47dd72fe7e2f782bbb to your computer and use it in GitHub Desktop.
Save akira345/54e876c9b7c80f47dd72fe7e2f782bbb to your computer and use it in GitHub Desktop.
GitHubから自分のリポジトリをまとめてcloneする。(公開リポジトリのみ)
# Use 'ruby clone-github.rb'
# ユーザー名とかdepthオプションは自分で書き換えてください。
require "json"
require "open-uri"
response = open("https://api.github.com/users/Hiroto-K/repos?per_page=100").read
JSON.parse(response).each do |info|
clone_url = info["ssh_url"]
to = info["name"]
if File.exists?(to)
puts "Skip '#{to}'"
next
end
puts "Clone '#{clone_url}' to '#{to}'"
puts %x(git clone #{clone_url} #{to})
end
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment