Skip to content

Instantly share code, notes, and snippets.

@aglove2189
Created November 1, 2018 16:16
Show Gist options
  • Save aglove2189/2bb964b929fb1f969e2a67ed2c89b7d7 to your computer and use it in GitHub Desktop.
Save aglove2189/2bb964b929fb1f969e2a67ed2c89b7d7 to your computer and use it in GitHub Desktop.
Bulk clone and/or pull a list of repos
# -*- coding: utf-8 -*-
import os
import re
pat = '\w*(?=\.git$)'
with open('git.sh', mode='w') as f:
f.write('#!/usr/bin/env bash\n')
for repo in repos:
repo_folder = re.search(pat, repo).group()
if os.path.exists(repo_folder):
cmd = 'cd {} && git pull origin master\n'.format(repo_folder)
f.write(cmd)
f.write('cd ..\n')
else:
cmd = 'git clone {}\n'.format(repo)
f.write(cmd)
#!/usr/bin/env bash
python git.py && ./git.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment