Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. from commands import getstatusoutput
  2.  
  3.  
  4. def branches(remote=False):
  5. command = "git branch" + (" -r" if remote else "")
  6. return [br.strip() for br in getstatusoutput(command)[1].replace("*", "").split("\n")]
  7.  
  8. local_branches = branches()
  9.  
  10. remote_branches = branches(remote=True)
  11.  
  12. missing_branches = []
  13.  
  14. for branch in remote_branches:
  15. _branch = branch.replace("origin/", "")
  16. if _branch not in local_branches and _branch.find(" -> ") == -1:
  17. missing_branches.append(_branch)
  18.  
  19. # git fetch
  20. _ = getstatusoutput("git fetch")
  21.  
  22. for branch in missing_branches:
  23. command = "git checkout "+branch
  24. resp = getstatusoutput(command)
  25.  
  26. # git pull --all
  27. _ = getstatusoutput("git pull --all")
  28.  
  29. # checkout latest version
  30. output = getstatusoutput("git checkout $(git log --branches -1 --pretty=format:\"%H\")")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement