Skip to content

Instantly share code, notes, and snippets.

@harshays
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshays/d7308c4e67b866ec6cd1 to your computer and use it in GitHub Desktop.
Save harshays/d7308c4e67b866ec6cd1 to your computer and use it in GitHub Desktop.
Clean up your github directory
'''
Snippet to interactively view statuses and enter commands of all repositories in a Github folder
purpose is to clean up any lingering modifications/added files yet to be committed
'''
import os
dirname = os.path.dirname(os.path.realpath(__file__))
folders = list(os.walk(dirname))[0][1]
folderspath = [os.path.join(dirname, f) for f in folders if not f.startswith(".")]
for folder in folderspath:
os.chdir(folder)
status = os.popen("git status").read()
if "up-to-date" in status:
continue
print "-"*10
print "STATUS for %s \n" % folder.rsplit('/', 1)[-1]
os.system("git status");
while True:
next_command = raw_input("enter command. enter 'no' to exit ->")
if next_command == 'no':
break
else:
os.system(next_command)
print '\n'*3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment