Skip to content

Instantly share code, notes, and snippets.

@Larusso
Created April 16, 2018 10:40
Show Gist options
  • Save Larusso/55c903f993d94af77d71cc80163fef18 to your computer and use it in GitHub Desktop.
Save Larusso/55c903f993d94af77d71cc80163fef18 to your computer and use it in GitHub Desktop.
A small helper file to run git commands over multiple repos
#!/usr/bin/env ruby
root = Dir.pwd
def each_repo(root, &block)
Dir.foreach(root) {|repo|
if File.directory?(File.join(root, repo)) and File.exist?(File.join(root, repo, '.git'))
block.call(File.join(root,repo), repo)
end
}
end
each_repo(root) {|repo_path, repo_name|
Dir.chdir(repo_path) do
puts repo_path
puts `git #{ARGF.argv.join(' ')}`
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment