Reputation: 1582
I want to clone a SVN tree into a git repo using git-svn. I'd like to make a complete clone, including tags and branches, but I hit a problem with the tags organization.
the SVN tags folder looks like this:
tags/
|-- Backup
| |-- 20080212
| `-- 20080217
|-- V4.0.1
|-- V4.0.2
`-- V4.0.3
I know about git svn clone -T trunk -b branches -t tags/Backup -t tags
with twice the -t
option, but this is not entirely satisfying:
$ git branch -r
tags/20080212
tags/20080217
tags/Backup
tags/V4.0.1
tags/V4.0.2
tags/V4.0.3
trunk
As you can see, all the tags are here, but one is too much: the Backup tag is actually not a tag but a folder containing tags. The problem is that it creates an orphan branch which duplicate the content of all the backup branches.
The question is: How do I make git-svn ignore the backup folder but know about the backup subfolders as tags, keeping the classical tags available?
And as a bonus: how to automatically name the Backup tags as Backup/20080217
instead of 20080217
?
Thanks!
Upvotes: 3
Views: 1244
Reputation: 8968
Use SmartGit to clone the repository, it creates correct tags, provides better translation and works faster than git-svn.
Upvotes: 0
Reputation: 15634
git svn
isn't intelligent enough to be able to ignore the Backup folder in one group of tags but include its subfolders. You've a bunch of options, none of which are great:
Change the underlying Subversion repository to move all the tags into subfolders, so your repository looks something like this:
tags/
|--Backup/
| |--20080212
| `--20080217
`--Versions/
|--V4.0.1
|--V4.0.2
`--V4.0.3
You can then use -t tags/Backup -t tags/Versions
to pick up all the tags.
Cope. While irritating, the way Git manages tree objects means having a "Backup" tag won't actually take any more space or slow down most Git operations; the only impact will be git svn fetch
es will take longer.
Write your own patch for git-svn
to enable handling this scenario. Bonus points if you get it included in future official Git releases.
Getting the tags to have a different name is fairly easy, at least. If you edit your .git/config
file, you should find a line that looks something like this:
tags = tags/Backup/*:refs/remotes/tags/*
You should be able to change this to the below instead:
tags = tags/Backup/*:refs/remotes/tags/Backup/*
If you do this between running git svn init
and the first git svn fetch
, everything should just work. Otherwise, you may need to manually remove the old references first, by deleting any files or folders with a name matching the tag name in .git/logs/refs/remotes/tags/
, .git/svn/refs/remotes/tags/
and .git/refs/remotes/tags
.
I have no idea what will happen if you have a tag called "Backup" and a folder of tags called "Backup", though. I suspect nothing good. You'll need to find some way of avoiding that, or store the Backup tags in a folder with a different name.
Upvotes: 3