Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git-svn - import full history

Tags:

git

svn

git-svn

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
like image 480
Hoppus Hoppard Avatar asked Mar 01 '13 17:03

Hoppus Hoppard


People also ask

How do I migrate an svn repository with history to a new Git repository?

Prepare a migration environment. Convert the source SVN repository to a local Git repository. (Optional) Synchronize the local Git repository with any changes from SVN repository while developers continue using SVN. Push the local Git repository to a remote Git repository hosted on Azure Repos.

How do I move svn code from github to history?

Migrate from SVN to Git with History and Branches Now that you have your list of authors ready, you can run the import using git svn and specify the authors-transform. txt . Copy the authors-transform. txt to a new directory C:/repo/temp and cd to that directory in the CLI.

Can I use Git and svn at the same time?

You can clone a subversion repository to your machine using git svn clone <SVN repo URL> . The code will be available as a git repository. You can do your work there and make local commits as you please. There is a command line option to get a "shallow" checkout rather than the entire repository which is often useful.


1 Answers

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).

like image 125
sleske Avatar answered Oct 14 '22 22:10

sleske