2

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.

Aleks Ya
  • 859
  • 5
  • 15
  • 27
  • possible duplicate of [How to git-svn clone the last n revisions from a Subversion repository?](http://stackoverflow.com/questions/747075/how-to-git-svn-clone-the-last-n-revisions-from-a-subversion-repository) – Lazy Badger Apr 08 '14 at 23:44

2 Answers2

1

Read git-svn man page carefully, pay attention to -r option and use -r HEAD on clone

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
1

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.

Mykola Gurov
  • 8,517
  • 4
  • 29
  • 27
  • Thanks for answer, Mykola! But `git svn fetch -r ` fetches nothing. Should I specify revision interval? It is equal to full history clone. – Aleks Ya Apr 16 '14 at 07:55
  • I am not sure why git-svn-fetch by last svn revision doesn't work to you. Could possibly be combination of versions svn server/client/git-svn. If revisions work to you instead, you could ask for very shallow history: `git svn fetch -r : or so. – Mykola Gurov Apr 16 '14 at 18:51
  • @MykolaGurov: in the git svn init command, do we provide a url for the trunk, for the branches, or the root url which contains both trunk and branches? For example, http://server/myrepo contains both trunk and branches folder, so are we to provide http://server/myrepo, http://server/myrepo/trunk or http://server/myrepo/branches//***? in case of git svn init? – Syed Waqas Apr 13 '16 at 10:34
  • @WaqasShah did you read https://www.kernel.org/pub/software/scm/git/docs/git-svn.html#_basic_examples ? – Mykola Gurov Apr 13 '16 at 10:59