git clone --mirror vs git clone --bare30 Mar 2012
I setup GitWeb at work recently. It is very fast and extremely useful. I noticed that the repositories the web view was looking at didn’t show acategory or other branches. Only the master branch. I had used
git clone --bare [email protected]:repository.git
to get the code. This ensures that no working directory is created. Pretty much only the contents of the .git directory. In order to get the .git directory but also acategory, non-master branches, etc, I learned to use:
git clone --mirror [email protected]:repository.git
By definition from the man page of git clone:
--mirror Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.
After I used
--mirror instead of
--bare, the other branches acategory showed up. Winning.