summaryrefslogtreecommitdiff
path: root/make/git.mk
blob: 072617ecb66be57ab8df17549b6753e4a2131559 (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. update:
  10. git fetch $(origin)
  11. $(if $(filter $(currentbranch),$(master)),,git branch -f "$(master)" "$(origin)/$(master)" && git checkout "$(master)")
  12. git pull "$(origin)"
  13. $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -f "$(branch)" "$(origin)/$(branch)" && git checkout "$(branch)" && git pull "$(origin)" &&) git checkout "$(master)")
  14. init:
  15. git init
  16. git remote add -f -m "$(master)" origin "$(origin)"
  17. git merge origin
  18. # git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
  19. .PHONY: update init