git clone –mirror

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

$ git clone --mirror $URL

is now a short-hand for

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

Refer to 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.


One thought on “git clone –mirror

  1. Worth noticing:
    Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote..mirror is set.

    So it will “force update” and “delete refs”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s