Skip to content

Instantly share code, notes, and snippets.

@eden
Created May 24, 2013 16:02
Show Gist options
  • Save eden/5644530 to your computer and use it in GitHub Desktop.
Save eden/5644530 to your computer and use it in GitHub Desktop.
Find dirty git repos in current directory
import stat
import os
for f in os.listdir("."):
if stat.S_ISDIR(os.stat(f).st_mode):
if not os.path.isdir(f + "/.git"):
continue
os.chdir(f)
sin, sout, serr = os.popen3("git branch")
branches = [b for b in map(str.strip, sout.readlines()) if b != "* master"]
sin, sout, serr = os.popen3("git ls-files --other --exclude-standard")
status = map(str.strip, sout.readlines())
if len(branches) > 0 or len(status) > 0:
print "%s: %s; %d" % (f, ",".join(branches), len(status))
os.chdir("..")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment