从没有 --stdlayout 的 Git-Svn 克隆中恢复
我不小心克隆了一个 Subversion 存储库,但没有添加 --stdlayout 参数, 给我类似的东西:
$ git svn clone --prefix=svn/ svn+ssh://code.example.com/project
[two weeks later]
$ git branch -a
* master
remotes/svn/git-svn
svn/git-svn 布局类似于: 有
branches/*
tags/*
trunk/*
什么方法可以从中恢复吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于:您希望将来能够与 subversion 进行互操作吗?
如果没有,请考虑在 git 中为
branches
中的每个分支手动创建一个分支,并将该分支目录的内容移至顶层。这给了你一个工作的承诺,并且 git 的重命名跟踪应该意味着查看历史记录效果相当好。如果您需要标签,您可以类似地为每个标签创建一个分支,对其进行标记,然后删除该分支。这不太漂亮,但应该可行。
更多的工作是使用 git filter-branch 来重写您刚刚创建的每个分支的历史记录,就像您重写提示一样。这应该会给您留下一个看起来正确的存储库。不过,您仍然无法获得颠覆集成,并且您必须弄清楚如何处理原始分支点。
更多的工作将是弄清楚 git svn 如何存储其元数据并相应地转换存储库(可能再次使用 git filter-branch) - 所有数据都应该在那里:)。
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 usinggit filter-branch
) accordingly -- all the data should be there :).目前看来,重新开始是保持与 SVN 互操作性的唯一选择。
Currently, it looks like a fresh start is the only option which will maintain interoperability with SVN.
这不是一个确切的答案,但我所做的是添加
-r
标志来指定最后几次提交,因为无论如何我并不真正想要一年前的提交。git svn clone --prefix=svn/ -s -r12000:HEAD http://some/svn/repo
这要求您知道要返回到哪个版本号,在本例中, 12000。它让我在错过
-s
标志后保持理智,并在合理的时间内做了我真正想做的事情。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.