Backup a GitHub repository

I am not sure it could cover all your requirements, but you could check out git bundle

git bundle

This command provides support for git fetch and git pull to operate by packaging objects and references in an archive at the originating machine, then importing those into another repository using git fetch and git pull after moving the archive by some means

What I like about that solution is the single file produced, with exactly what I want in it

git bundle will only package references that are shown by git-show-ref: this includes heads, tags, and remote heads.

machineA$ git bundle create file.bundle master

Note: Kent Fredric mentions in the comments a subtlety from git rev-list:

--all

Pretend as if all the refs in $GIT_DIR/refs/ are listed on the command line as <commit>.

He adds:

your current bundle will only bundle parents of the commit, you'd probably need to specify --all to get a complete bundle of everything (branches that are descendant of master).

To see the difference:

$ git bundle create /tmp/foo master
$ git bundle create /tmp/foo-all --all
$ git bundle list-heads /tmp/foo
$ git bundle list-heads /tmp/foo-all

To create the mirror:

git clone --mirror git://github.com/user/project.git

To update:

cd project.git
git remote update

To update without changing the current directory:

git --git-dir project.git remote update

Tags:

Git

Backup