Recover from Git-Svn clone without --stdlayout

拟墨画扇 提交于 2019-12-12 07:59:48

问题


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?


回答1:


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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/4249129/recover-from-git-svn-clone-without-stdlayout

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!