Created
April 15, 2019 15:42
-
-
Save damilare/503164aefb10d91eacaa56530a14c2f1 to your computer and use it in GitHub Desktop.
Clone all repost, or update its master branch
This file contains 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 | |
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