Skip to content

Instantly share code, notes, and snippets.

@damilare
Created April 15, 2019 15:42
Show Gist options
  • Save damilare/503164aefb10d91eacaa56530a14c2f1 to your computer and use it in GitHub Desktop.
Save damilare/503164aefb10d91eacaa56530a14c2f1 to your computer and use it in GitHub Desktop.
Clone all repost, or update its master branch
import os
import subprocess
with open('repos.txt') as f:
for repo in f.readlines():
dir_name = repo.split('/')[1].split('.')[0]
if os.path.exists(dir_name):
print("Updating ... %s" % dir_name)
subprocess.run(['git', '-C', dir_name, 'checkout', 'master'])
subprocess.run(['git', '-C', dir_name, 'pull', 'origin', 'master'])
else:
print("Cloning... %s" % repo)
subprocess.run(['git', 'clone', repo.strip()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment