Reputation: 909
I need to import svn repo (trunk, branches, tags) to new empty git repo WITHOUT history. Svn history is very large, because many branches and tags exist.
Svn's trunk must get into git's master. Svn's branches must get into git's branches. And svn's tags must get into git's tags. All without history.
This command will import with history:
git svn clone http://server.ru/myrepo/ --stdlayout --preserve-empty-dirs .
Do branches and tags import by hands (checkout each from svn and commit to git) is too laborious.
Upvotes: 2
Views: 8511
Reputation: 8705
Advised -r HEAD
seems to be getting the latest trunk revision only, but ignores branches and tags. Moreover, in my test it failed the execution of git-svn clone when last commit to repository was not to trunk.
What you could try is fetching trunk, branches and tags individually. First init empty git-svn repository:
git svn init http://server.ru/myrepo/ --stdlayout .
Then for each of trunk, tags, branches find their latest svn revision and do git-svn-fetch:
git svn fetch -r <svn revision>
To avoid manual labor, you could probably create a simple script that would parse the output of the svn ls -v <svn_path>/branches
or svn ls --xml <svn_path>/tags
.
Alternatively, if you already have git-svn-imported repository but want to strip the history, you could do for each branch/trunk: git checkout --orphan <branch> && git commit -m "as imported from svn"
- that will produce a bunch of detached branches that you can further push to a new "clean" git repository.
Upvotes: 1
Reputation: 97345
Read git-svn man page carefully, pay attention to -r
option and use -r HEAD
on clone
Upvotes: 1