Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I migrate a flat svn repo to git repo

I have a flat svn repository which looks like:

my_repo/
├── file1.c
├── file2.c
├── file3.c
└── README

This repo has no branches, or tags and all I am trying to do is convert it to a git repository and maintain the commit history.

I have tried:

git svn clone --trunk=/ -A users.txt svn+ssh://[email protected]/projects/my_repo dest_dir

Which I assumed would work, however, when I navigate into dest_dir and perform git svn fetch, it doesn't seem to fetch anything. Using git log yields:

fatal: bad default revision 'HEAD'

If I use svn checkout svn+ssh://[email protected]/projects/my_repo it returns:

A    my_repo/file1.c
A    my_repo/file2.c
A    my_repo/file3.c
A    my_repo/README
Checked out revision 57.

So the repository is alive and accessible.

I have tried various tools including subgit which was giving me this error: svn: E170003: 'stat' not implemented and I think this is because the server hosting the repository is using an old version of subversion. I have no control over the server so cannot perform an update.

I have also tried using the svn2git, using the command

svn2git svn+ssh://[email protected]/projects/my_repo --rootistrunk -authors users.txt --verbose

but this was giving me another error:

E: 'svn+ssh:/[email protected]/projects/my_repo' is not a complete URL and a separate URL is not specified command failed

This stumped me, and I've no idea why it's not working. Basically I was wondering how I go about turning my svn repo into a git repo while maintaining the history. Hope someone can help me out, or point me in the right direction. Never realised it would be so difficult to transfer this simple repo to git!

Thanks

like image 619
user3277112 Avatar asked Apr 04 '14 19:04

user3277112


People also ask

Can you convert SVN to git?

The high-level workflow for migrating from SVN to Git is as follows: 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.

Which migration is actually recommended for migration from SVN to git?

Migrate from SVN to Git with History and Branches txt file to match the syntax you need for your Git author information. 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.

How do I clone a Subversion repository?

You can clone from a SVN repo using the git svn clone command. -s = If your SVN repo follows standard naming convention where main source is in “trunk”, branches are created in “branches”.

What is SVN migration?

SVN is a popular tool for code hosting. It is used to manage different versions of files like source code, documentation and more. It keeps history and project data. Subversion is an open-source tool and comes under the Apache License.

Does git support SVN?

Git allows you to modify previous commits and changes using tools like git rebase . GitHub supports Subversion clients, which may produce some unexpected results if you're using both Git and SVN on the same project. If you've manipulated Git's commit history, those same commits will always remain within SVN's history.


1 Answers

The problem is with svn2git's --rootistrunk argument. Instead of that, try this:

svn2git svn+ssh://[email protected]/projects/my_repo --trunk / --notags --nobranches --authors users.txt --verbose
like image 194
Nick K9 Avatar answered Sep 21 '22 14:09

Nick K9