Skip to content

Instantly share code, notes, and snippets.

@rathankalluri
Created August 17, 2020 05:00
Show Gist options
  • Save rathankalluri/ee2f49ed9f7ed376ae8f893a99781c72 to your computer and use it in GitHub Desktop.
Save rathankalluri/ee2f49ed9f7ed376ae8f893a99781c72 to your computer and use it in GitHub Desktop.
Update multiple repos at once
# Feel free to use and modify
import os
import re
import git
pattern = r"^9\d{2}-.*" #Give some pattern of repos if needed
for name in os.listdir("."):
parent_dir = os.getcwd()
if os.path.isdir(name) and re.match(pattern, name):
os.chdir(name)
repo = git.Repo()
print(repo)
try:
repo.branches['dev'].checkout()
repo.remotes.origin.pull()
except Exception as e:
continue
print(name+" got pulled to latest")
os.chdir(parent_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment