2008年 05月 22日

push し忘れているローカルの git repos を列挙する

`locate /.git/`.split(/\n/).map {|l| l.gsub(%r|/\.git/.+|, "") }.uniq.each {|repo|
	Dir.chdir(repo) do
		head =  `git rev-parse HEAD`.chomp
		remotes = `git rev-parse --remotes`.split(/\n/)
		unless remotes.include? head
			puts repo
		end
	end
}

このコードだと、登録してある remote のうち、少くとも一つに push されていればいい、っていうことになります。

なんかもっといい方法はないかしら