Skip to content

Automatic Updates

hilbix edited this page Dec 16, 2012 · 13 revisions

If nothing breaks, one of my hosts essentially runs following each day now via CRON to keep this mirror here updated:

git checkout -q "`git rev-parse HEAD`"
git remote update --prune
git for-each-ref --shell --format='[ -z %(upstream:short) ] || git update-ref %(refname) %(upstream:short)' refs/heads | bash
git push --mirror origin

Note that I cannot use --mirror on the sources, as two repos shall be combined.

Explained:

  • First: Move away the currently checked from the current branch, such that the update-ref can be used safely
  • Second: Pull all remotes
  • Third: Move the refs (branches) to their tracking position. This works as we are in detached head state (see First:)
  • Last: Push this to GitHub

Clone this wiki locally