简体   繁体   English

如何克隆非标准的svn repo到git?

[英]How to clone a nonstandard svn repo to git?

I try to clone a svn repo to git, but some of the branches are in the svn root dir like follows. 我尝试将svn repo克隆到git,但是一些分支在svn根目录中,如下所示。

I've tried 我试过了

$ git clone svn://url/svn-root -T trunk -b branches -b branch1 -b branch2

and

$ git clone svn://url/svn-root -T trunk -b branches -b .

Both are failed to clone the branch1 and branch2 correctly. 两者都无法正确克隆branch1branch2 Please help. 请帮忙。

svn-root
├── branch1
├── branch2
├── branches
│   ├── branch3
│   └── branch4
└── trunk

One interesting tool, mentioned in GitMinutes Episode 20 , is SubGit , a plugin for Atalssian Stash (which isn't free, but you can try it for free). GitMinutes第20集中提到的一个有趣的工具是SubGit ,它是Atalssian Stash的插件(它不是免费的,但你可以免费试用)。
You can know much more about SubGit in " GitMinutes #22: Alexander Kitaev about SubGit ". 您可以在“ GitMinutes#22:Alexander Kitaev关于SubGit ”中了解更多有关SubGit的信息

It is designed to managed unconventional svn repo layout. 它旨在管理非传统的svn repo布局。

http://subgit.com/img/stash/105_repository_layout.png

Dmitry Pavlenko comments : 德米特里·帕夫连科 评论道

you should enter in the "Branches" field: 你应该进入“分支”字段:

*:refs/heads/*;branches/*:refs/heads/branches/* 
# instead of 
branches/* 

In this case branch1 will be translated to refs/heads/branch1 , 在这种情况下, branch1将被转换为refs/heads/branch1
branch3 --- to refs/heads/branches/branch3 . branch3 --- to refs/heads/branches/branch3

Alternatively, if you have limited number of top-level branches, you can enumerate them explicitly: 或者,如果您具有有限数量的顶级分支,则可以显式枚举它们:

branch1:refs/heads/branch1;
branch2:refs/heads/branch2;
branches/*:refs/heads/bra‌​nches/*

Two options come to mind: 我想到两个选择:

  • Clean up your SVN repo first (Move branches below /branches, where they should be according to standard layout). 首先清理SVN仓库(在分支下方移动分支,根据标准布局移动分支)。
  • Checkout using standard layout, add remote branch refs later on. 使用标准布局结帐,稍后添加远程分支引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM