Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recover from Git-Svn clone without --stdlayout

Tags:

git

git-svn

I've accidentally cloned a Subversion repository without adding the --stdlayout argument, giving me something like:

$ git svn clone --prefix=svn/ svn+ssh://code.example.com/project
[two weeks later]
$ git branch -a                                                                                                
* master
  remotes/svn/git-svn

With the svn/git-svn layout being something like:

branches/*
tags/*
trunk/*

Any way to recover from this?

like image 260
Dwight Holman Avatar asked Nov 22 '10 18:11

Dwight Holman


People also ask

How do I move SVN code from GitHub to history?

Migrate from SVN to Git with History and Branches You will now need to edit each author in the author-transformed. 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 .


3 Answers

That depends: do you want to be able to interoperate with subversion in the future?

If not, consider manually creating a branch in git for each branch in branches and moving the contents of that branch directory up to the top level. That gives you a commit to work from, and git's rename tracking should mean that looking at the history works reasonably well. If you want tags, you could similarly create a branch for each tag, tag it, then delete the branch.

This isn't pretty, but it should be workable.

More work would be to use git filter-branch to re-write the history of each of the branches you've just created in the same way that you re-wrote the tip. This should leave you with a repository that looks correct. You still wouldn't get subversion integration, though, and you'd have to work out how to deal with the original branch point.

Much, much more work would be to work out how git svn stores its metadata and transform the repository (probably again using git filter-branch) accordingly -- all the data should be there :).

like image 139
Andrew Aylett Avatar answered Oct 21 '22 11:10

Andrew Aylett


Currently, it looks like a fresh start is the only option which will maintain interoperability with SVN.

like image 21
Dwight Holman Avatar answered Oct 21 '22 11:10

Dwight Holman


It's not an exact answer, but what I did was add the -r flag to just specify the last few commits, since I didn't really want commits from a year ago anyway.

git svn clone --prefix=svn/ -s -r12000:HEAD http://some/svn/repo

This requires that you know what rev number you want to go back to, in this case, 12000. It allowed me to keep my sanity after missing the -s flag and did what I really wanted to do in the first place in a reasonable amount of time.

like image 36
Kyle Heironimus Avatar answered Oct 21 '22 10:10

Kyle Heironimus