Created
May 6, 2015 22:32
-
-
Save xlarsx/2eeaa7199f69af64b9f2 to your computer and use it in GitHub Desktop.
Git: Load All Branches
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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
import os | |
import git | |
from gitdb import GitDB | |
basePath = "." | |
reposPath = ["billsios7"] | |
def loadLastBranches(): | |
for repoPath in reposPath: | |
path_join = os.path.join(basePath, repoPath) | |
if os.path.isdir(path_join): | |
repo = git.Repo(path_join, odbt=GitDB) | |
repoOrigin = repo.remotes.origin | |
repoOrigin.fetch() | |
for referencia in repoOrigin.refs: | |
nombreReferencia = referencia.name | |
if nombreReferencia[:6] == "origin" and not nombreReferencia[7:] == "HEAD" : | |
nombreReferencia = nombreReferencia[7:] | |
repo.create_head(nombreReferencia, referencia, force=True) | |
if __name__ == "__main__": | |
try: | |
loadLastBranches() | |
except Exception, e: | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment