git clone –mirror

It seems there will be a new option for git-clone, ‘–mirror’. The command line

1
$ git clone --mirror $URL

is now a short-hand for

1
2
$ git clone --bare $URL
$ (cd $(basename $URL) && git remote add --mirror origin $URL)

Refer to http://kerneltrap.org/mailarchive/git/2008/8/2/2793244 about this.

This is extremely useful if you need to check the contents of different branches in different directories at the same time. Each directory will be a local git clone -l -s, and git push will use --mirror as well by default.