I have a bunch(10-15) of local git repositories somewhere on my filesystem, but all in the folder /data/
I want to find all/any folder that has uncommitted changes. How can I do that? Kind of like a recursive global git status
variant.
All the answers got it wrong I think. Any git command only works within the folder that's under git control. I need something to search for such folders.
So instead I wrote this script that does this:
#!/usr/bin/env ruby
require 'find'
require 'fileutils'
#supply directory to search in as argument
@pat = ARGV[0]
(puts "directory argument required"; exit) unless @pat
Dir.chdir(@pat)
Find.find(@pat) do |path|
if FileTest.directory?(path)
Dir.chdir(path)
resp = `git status 2>&1`
unless resp =~ /fatal|nothing to commit (working directory clean)/i
puts "#{'#'*10}
#{Dir.pwd}#{'#'*10}
#{resp}"
Find.prune
end
Dir.chdir(@pat)
end
end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…