Skip to content

Instantly share code, notes, and snippets.

@mislav
Created September 5, 2008 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mislav/8920 to your computer and use it in GitHub Desktop.
Save mislav/8920 to your computer and use it in GitHub Desktop.
a utility to execute commands entered in the console in several git repositories at once
#!/usr/bin/env ruby
# for each git repo in a subdirectory ...
dirs = Dir['**/.git'].map { |gd| File.dirname(gd) }
def prompt
print ">> "
gets
end
# ... execute a command given on STDIN
while command = prompt
dirs.each do |dir|
Dir.chdir(dir) do
puts "~ #{dir}:"
system command
end
end
end
# (press Ctrl+D to break out of the loop)
# usage:
$ cd ~/Library/Application\ Support/TextMate/Bundles
$ each-git
>> git config remote.origin.url
~ AsciiDoc.tmbundle:
git://github.com/zuckschwerdt/asciidoc.tmbundle.git
~ Git.tmbundle:
git://gitorious.org/git-tmbundle/mainline.git
~ GitHub.tmbundle:
git://github.com/drnic/github-tmbundle.git
~ RSpec.tmbundle:
git://github.com/dchelimsky/rspec-tmbundle.git
~ Ruby on Rails.tmbundle:
git://github.com/drnic/ruby-on-rails-tmbundle.git
~ Ruby.tmbundle:
git://github.com/drnic/ruby-tmbundle.git
>> git pull
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment