I have a local git repo that I created from an svn repo:
$ git svn clone -s svn:...
I then created a backup remote and pushed everything to it:
$ git remote add backup git@myhost:mybackup.git
$ git push --mirror backup
Now, when I try to clone from my backup, it is missing all svn tags and branches.
$ git clone git@myhost:mybackup.git
$ cd mybackup
$ git branch -a
* master
origin
remotes/origin/HEAD -> origin/master
remotes/origin/master
How do I clone the repo with all tags and branches?
The only way I have found is to mirror the repo:
$ git clone --mirror git@myhost:mybackup.git
This creates a local mybackup.git
directory, which knows about all tags/branches (I can use tab completion to get the entire list) but it is not a valid usable repo:
$ git checkout mytag
fatal: This operation must be run in a work tree
There must be command line option to truly clone the repo with all branches/tags???
I have found several related questions here but none of the answers work for this situation. I assume the difference is that my clone was created with --mirror
?
There are two ways to improve your command git clone --mirror git@myhost:mybackup.git
The one I found is this one, knowing that your command created a mybackup.git directory :
mkdir mybackup
mv mybackup.git mybackup/.git
cd mybackup
git init
There, you have a full working directory.
Alternatively as you can read on this page : https://git.wiki.kernel.org/index.php/Git_FAQ#How_do_I_clone_a_repository_with_all_remotely_tracked_branches.3F
git clone --mirror git@myhost:mybackup.git mybackup/.git
cd mybackup
git config --bool core.bare false
I think both are equivalent up to the last line, and probably the command git config --bool core.bare false
is cleaner than doing a git init
.
It all sums up to the fact that --mirror creates a bare repository and not a working repository, so you need to transform it into a working repository.