Created
August 17, 2020 05:00
-
-
Save rathankalluri/ee2f49ed9f7ed376ae8f893a99781c72 to your computer and use it in GitHub Desktop.
Update multiple repos at once
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
# 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