Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created May 3, 2011 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdelStrother/953158 to your computer and use it in GitHub Desktop.
Save jdelStrother/953158 to your computer and use it in GitHub Desktop.
#!/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