14

Problem

By default git svn clone imports history only from branch creation onwards, despite the fact, that history for files is present in SVN repository prior branch creation.

Our SVN branch was created by svn copy, if that matters.

My attempts

I've tried --no-minimize-url and --follow-parent, but without success. Produced Git repository is same as without these params, starting from branch creation.

Desired result

Git repository with full history from SVN repository creation.

Update

My actual command line was

git svn clone http://svnserver/repo/dir1/dir2/project

What helped was -T argument with resulting command:

git svn clone http://svnserver/repo/ -T dir1/dir2/project
dur
  • 15,689
  • 25
  • 79
  • 125
Hoppus Hoppard
  • 481
  • 1
  • 4
  • 15
  • have you tried with the -T flag? git svn clone -T repo_url? –  Mar 01 '13 at 17:57
  • @Kata, I aren't you refering to `-s` flag? Standard layout. It assumes the standard trunk/branches/tags directory format, so it imports all branches and tags from SVN repository. I've found http://jonmaddox.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/ particularly useful for migrating. – mgarciaisaia Mar 01 '13 at 20:19

2 Answers2

10

By default git svn clone imports history only from branch creation onwards, despite the fact, that history for files is present in svn repository prior branch creation.

Yes. that is true. git svn will only try to import branches as branches if it is told so. From the manpage of git-svn:

When cloning an SVN repository, if none of the options for describing the repository layout is used (--trunk, --tags, --branches, --stdlayout), git svn clone will create a git repository with completely linear history, where branches and tags appear as separate directories in the working copy.

If you pass the URL for one branch to git svn clone (instead of the top-level URL), you'll only get the linear history for that branch. That is probably what you are seeing.

If you want full history, use the repository layout options mentioned above, and pass the top-level URL. Then git svn will try to create git branches for SVN branches, and will try to give them the right history, going back before their creation.

Note that this will give you the complete repository with all branches. If you only want some branches, you need to modify your configuration as explained in the manpage:

It is also possible to fetch a subset of branches or tags by using a comma-separated list of names within braces. For example:

       [svn-remote "huge-project"]
               url = http://server.org/svn
               fetch = trunk/src:refs/remotes/trunk
               branches = branches/{red,green}/src:refs/remotes/branches/*
               tags = tags/{1.0,2.0}/src:refs/remotes/tags/*

See git-svn(1).

sleske
  • 81,358
  • 34
  • 189
  • 227
  • 4
    If you specify multiple single branches as multiple `svn-remote.{name}.fetch` config options (you need to do this by hand between running `git svn init` and the first `git svn fetch`, no `git svn clone short-cut here), you can fetch a handful of specific branches, including the branch history between them. – me_and Mar 04 '13 at 15:23
  • if the trunk path had been renamed (for ex, trunk/dev), then history part of trunk before the renaming not being imported. Any ideas? – Minh Nguyen Nov 14 '19 at 12:13
  • @MinhNguyen: That sounds like a new question. Consider asking it as such :-). – sleske Nov 14 '19 at 12:30
1

http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git describes how to import branches and tags properly.

sjas
  • 18,644
  • 14
  • 87
  • 92