简体   繁体   English

使用 git-svn clone 克隆非标准 svn 存储库的缺失分支

[英]Missing branches cloning a non-standard svn repository using git-svn clone

I am a complete git newbie and I want to clone my svn repository using git-svn.我是一个完整的 git 新手,我想使用 git-svn 克隆我的 svn 存储库。 However, the branches are missing after the clone command is run.但是,运行 clone 命令后分支丢失了。

The repo layout is as follows:回购布局如下:

trunk/
branches/team/releases/release-1
branches/team/releases/release-2
...
branches/development/user1/feature1
branches/development/user1/feature2
branches/development/user2/feature3
branches/development/user2/feature4
...
tags/release1
tags/release2

The command I'm using is:我使用的命令是:

git svn clone --trunk=/trunk --branches=branches/*/* --tags=tags/*/* --prefix=svn/ --authors-file=authors.txt <my-repo> <git-repo-name>

I've tried modifying the branches option to /branches/development/user1/* and /branches/development/user1/*/* (and also using both together) and running the clone command again to see if any additional branches are picked up but they're not.我已经尝试将分支选项修改为/branches/development/user1/*/branches/development/user1/*/* (并且也一起使用)并再次运行clone命令以查看是否有任何其他分支被拾取但他们不是。

Is it OK to run clone again or to I have to start from scratch and delete the git repo?可以再次运行clone还是我必须从头开始并删除 git repo?

All I can see if I run git branch -r after cloning is:如果我在克隆后运行git branch -r ,我所能看到的就是:

svn/development/user1
svn/development/user1
svn/team/releases
svn/trunk
note that all the tags are present but omitted for brevity

How do I get the missing branches?我如何获得丢失的分支?

This is not a duplicate of Cloning a Non-Standard Svn Repository with Git-Svn or how to use nested branches through git-svn .这不是Cloning a Non-Standard Svn Repository with Git-Svn如何通过 git-svn 使用嵌套分支的副本。

It is in fact possible to do this without re-cloning the entire repository which can take many hours for a large subversion repository.事实上,无需重新克隆整个存储库就可以做到这一点,这对于大型 subversion 存储库可能需要数小时。 I did this by editing the config file in the .git directory to get my branches and tags setup appropriately.我通过编辑.git目录中的config文件来正确设置我的分支和标签。

If you do a plain git svn fetch , nothing will happen.如果你做一个普​​通的git svn fetch ,什么都不会发生。 The trick is to trick/force Git to refetch all the revisions:诀窍是欺骗/强制 Git 重新获取所有修订:

git svn fetch 0:HEAD

This command causes all the tags/branches to be brought in without going through the long and tedious import of the trunk, it was smart enough to skip the trunk revisions already imported in the initial run.此命令导致所有标签/分支都被引入,而无需经历冗长乏味的主干导入,它足够聪明,可以跳过在初始运行中已经导入的主干修订。 I now have my SVN tags/branches in my existing Git repository without a fresh clone.我现在在我现有的 Git 存储库中有我的 SVN 标签/分支,而没有新的克隆。

You can specify the --branches tag more than once.您可以多次指定 --branches 标签。 From the docs :从文档

These are optional command-line options for init.这些是 init 的可选命令行选项。 Each of these flags can point to a relative repository path (--tags=project/tags) or a full url (--tags= https://foo.org/project/tags ).这些标志中的每一个都可以指向相对存储库路径 (--tags=project/tags) 或完整 url (--tags= https://foo.org/project/tags )。 You can specify more than one --tags and/or --branches options, in case your Subversion repository places tags or branches under multiple paths.您可以指定多个 --tags 和/或 --branches 选项,以防您的 Subversion 存储库在多个路径下放置标签或分支。 The option --stdlayout is a shorthand way of setting trunk,tags,branches as the relative paths, which is the Subversion default.选项 --stdlayout 是将主干、标签、分支设置为相对路径的一种简写方式,这是 Subversion 的默认设置。 If any of the other options are given as well, they take precedence.如果还给出了任何其他选项,则它们优先。

In your case, try:在您的情况下,请尝试:

git svn clone \
  --branches=branches/team/releases/* \
  --branches=branches/development/user1/* \
  --branches=branches/development/user2/* \

...etc. ...等等。

Is it OK to run clone again or to I have to start from scratch and delete the git repo?可以再次运行 clone 还是我必须从头开始并删除 git repo?

Generally speaking you ought to try from scratch.一般来说,你应该从头开始尝试。 The tool is not meant to be an update script.该工具并不是一个更新脚本。

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

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