Last active
August 29, 2015 14:23
-
-
Save fprieur/f13477af45d88440a43b to your computer and use it in GitHub Desktop.
find all .git directories and change the remote origin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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