Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from commands import getstatusoutput
- def branches(remote=False):
- command = "git branch" + (" -r" if remote else "")
- return [br.strip() for br in getstatusoutput(command)[1].replace("*", "").split("\n")]
- local_branches = branches()
- remote_branches = branches(remote=True)
- missing_branches = []
- for branch in remote_branches:
- _branch = branch.replace("origin/", "")
- if _branch not in local_branches and _branch.find(" -> ") == -1:
- missing_branches.append(_branch)
- # git fetch
- _ = getstatusoutput("git fetch")
- for branch in missing_branches:
- command = "git checkout "+branch
- resp = getstatusoutput(command)
- # git pull --all
- _ = getstatusoutput("git pull --all")
- # checkout latest version
- output = getstatusoutput("git checkout $(git log --branches -1 --pretty=format:\"%H\")")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement