开发者

Recover from Git-Svn clone without --stdlayout

开发者 https://www.devze.com 2023-01-26 22:35 出处:网络
I\'ve accidentally cloned a Subversion repository without adding the --stdlayout argument, giving me something like:

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               开发者_Go百科                                                                                 
* master
  remotes/svn/git-svn

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

branches/*
tags/*
trunk/*

Any way to recover from this?


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消