Skip to content

Instantly share code, notes, and snippets.

@damilare
Created April 15, 2019 15:42
Show Gist options
  • Select an option

  • Save damilare/503164aefb10d91eacaa56530a14c2f1 to your computer and use it in GitHub Desktop.

Select an option

Save damilare/503164aefb10d91eacaa56530a14c2f1 to your computer and use it in GitHub Desktop.

Revisions

  1. damilare created this gist Apr 15, 2019.
    13 changes: 13 additions & 0 deletions clone_or_update_repo.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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()])