Skip to content

Instantly share code, notes, and snippets.

@matthewmayer
Last active December 18, 2015 02:29
Show Gist options
  • Save matthewmayer/5711274 to your computer and use it in GitHub Desktop.
Save matthewmayer/5711274 to your computer and use it in GitHub Desktop.
Check if all your git repos are synced with a server
#!/usr/bin/python
import glob
import os
import subprocess
folders = glob.glob("*")
for f in folders:
if os.path.isdir(f):
config = f+"/.git/config"
if not os.path.exists(config):
print "%s appears not to be a Git repo" % f
else:
configdata = open(config).read()
sips = subprocess.Popen(["git","status"], stdout=subprocess.PIPE,cwd=f)
output = sips.stdout.read()
if "working directory clean" not in output:
print "%s has uncommitted changes" % f
elif "Your branch is" in output:
print "%s has unpushed changes" % f
elif "[remote \"origin\"]" not in configdata:
print "%s has no configured origin" % f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment