Created
May 3, 2011 10:56
-
-
Save jdelStrother/953158 to your computer and use it in GitHub Desktop.
This file contains 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/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'json' | |
# Clone a github repo, add all forks as remotes: | |
# $ git clone https://github.com/rails/rails.git | |
# $ cd rails | |
# $ git add-github-forks | |
origin_url = `git config remote.origin.url`.chomp | |
source = origin_url.scan(%r{github\.com/([^/]+/[^/]+).git\z}).to_s | |
raise "Unsupported url #{origin_url}" unless source.length>0 | |
network = JSON.parse(open("http://github.com/api/v2/json/repos/show/#{source}/network").read) | |
network['network'].each do |fork| | |
url = fork['url'] + '.git' | |
owner = fork['owner'] | |
`git remote add #{owner} #{url}; git fetch #{owner}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment