Skip to content

Instantly share code, notes, and snippets.

@mipearson
Created August 18, 2011 00:31
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 mipearson/1153008 to your computer and use it in GitHub Desktop.
Save mipearson/1153008 to your computer and use it in GitHub Desktop.
find git repositories that are behind their current remote tracking branch
#!/usr/bin/env ruby
pwd = ARGV[0] || '.'
debug = ARGV[1] == '-d'
Dir[File.join(pwd, '**', '.git')].each do |repo|
repo.gsub!(/\.git$/, '')
$stderr.puts "in #{repo}" if debug
if `cd #{repo}; git status`.include?("Your branch is ahead of")
puts repo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment