Skip to content

Instantly share code, notes, and snippets.

@xlarsx
Created May 6, 2015 22:32
Show Gist options
  • Save xlarsx/2eeaa7199f69af64b9f2 to your computer and use it in GitHub Desktop.
Save xlarsx/2eeaa7199f69af64b9f2 to your computer and use it in GitHub Desktop.
Git: Load All Branches
#!/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