Created
April 27, 2011 00:54
-
-
Save ayosec/943519 to your computer and use it in GitHub Desktop.
Nasty way to add every fork of a GitHub repository
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 | |
# Nasty way to add every fork of a GitHub repository | |
if ARGV.size != 2 | |
puts "Use: #$0 owner repository" | |
exit 1 | |
end | |
current_remotes = File.read(".git/config").scan(/\[remote "(.*?)"\]/).flatten | |
require 'json' | |
JSON.parse(`GET https://github.com/#{ARGV[0]}/#{ARGV[1]}/network/members.json`)["users"].each do |item| | |
owner = item["owner"]["login"] | |
if not current_remotes.include?(owner) | |
git_url = "git://github.com/#{owner}/#{ARGV[1]}.git" | |
puts "Adding #{owner}: #{git_url}" | |
system "git remote add #{owner} #{git_url}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To fetch every remote:
$ git remote | xargs -l1 git fetch