summaryrefslogtreecommitdiff
path: root/make/git.mk
blob: 00594487ad6ba61c0fb8b9ea27bac665717f8cf1 (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 merge --no-commit "$(origin)"
  13. $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -f "$(branch)" "$(origin)/$(branch)" && git checkout "$(branch)" && git merge --no-commit "$(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