Skip to content

Instantly share code, notes, and snippets.

@fprieur
Last active August 29, 2015 14:23
Show Gist options
  • Save fprieur/f13477af45d88440a43b to your computer and use it in GitHub Desktop.
Save fprieur/f13477af45d88440a43b to your computer and use it in GitHub Desktop.
find all .git directories and change the remote origin
import os
from subprocess import Popen, PIPE
current_dir = os.path.dirname(os.path.realpath(__file__))
for dirname, dirnames, filenames in os.walk(current_dir):
for subdirname in dirnames:
if '.git' in subdirname:
commands = "cd " + os.path.join(dirname, subdirname) + \
"; git remote -v"
proc = Popen([commands], stdout=PIPE, shell=True)
output = proc.communicate()[0].strip()
print(os.path.join(dirname, subdirname))
print output + "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment