Skip to content

Instantly share code, notes, and snippets.

@matthew-brett
Created September 6, 2013 22:23
Show Gist options
  • Save matthew-brett/6470792 to your computer and use it in GitHub Desktop.
Save matthew-brett/6470792 to your computer and use it in GitHub Desktop.
import os
from os.path import join as pjoin, isdir
import sys
import shutil
from subprocess import call
input_dir = '/Users/mb312/dev_trees'
output_dir = os.getcwd()
for dir in sorted(os.listdir(input_dir)):
if dir.startswith('.'):
continue
this_dir = pjoin(input_dir, dir)
if not isdir(this_dir):
continue
that_dir = pjoin(output_dir, dir)
if isdir(that_dir):
continue
print(this_dir)
if isdir(pjoin(this_dir, '.git')):
print('Cloning')
os.chdir(this_dir)
try:
call(['git', 'fetch', '--all'])
call(['git', 'tff'])
finally:
os.chdir(output_dir)
call(['git', 'clone', this_dir])
else:
print('Copying')
shutil.copytree(this_dir, pjoin(output_dir, dir), symlinks=True)
@matthew-brett
Copy link
Author

Get all the repos on my machine, updating git repos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment