summaryrefslogtreecommitdiff
path: root/make/git.mk
blob: 559505708cbb760f1cdec114e2690a121a210694 (plain)
  1. # main local branch (the one we want checked out)
  2. master = master
  3. # all local branches (including those needed by child clones)
  4. branches = $(master)
  5. # local name of origin
  6. origin = origin
  7. currentbranch := $(shell git branch | grep ^\* | awk '{ print $2 }')
  8. noncurrentbranches := $(filter-out $(currentbranch),$(branches))
  9. #originbranches := $(shell git branch -r | perl -ne 'm,^.\s+'"$$origin"'/([a-z_]\S+)$, && print "$$1\n"' )
  10. localbranches := $(shell git branch | perl -ne 'm,^.\s+([a-z_]\S+)$$, && print "$$1\n"' )
  11. update:
  12. git fetch $(origin)
  13. for branch in $(filter-out $(localbranches),$(branches)); do \
  14. git branch $$branch $(origin)/$(branch); \
  15. done
  16. git checkout $(master)
  17. git pull $(origin)
  18. for branch in $(noncurrentbranches); do \
  19. git checkout $(branch); \
  20. git pull $(origin); \
  21. done
  22. init:
  23. git init
  24. git remote add -f -m "$(master)" origin "$(origin)"
  25. git merge origin
  26. # git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
  27. .PHONY: update init