使用 git-svn 访问混合分支文件夹布局

发布于 2024-11-03 19:36:59 字数 667 浏览 1 评论 0原文

我正在尝试使用 git svn 连接到我们公司的存储库。我们有一个稍微不标准的分支目录。之前已经讨论过如何使用 git svn 访问它,但是,我们的分支名称似乎有一个轻微的变化,这似乎阻止了我获取它们。

让我们考虑一个 svn repo 示例:

trunk/
tags/
branches/
    rootbranch/
    tku/subbranch

我们在分支目录的根级别有分支。但我们在嵌套文件夹中也有分支。标签目录也是如此,但我认为这只是同一问题的第二个例子。

如果我使用 git svn clone file:///tmp/gitsvn/svnrepo git-clone -s ,我只会得到根分支,如预期的那样:

/tmp/gitsvn/git-clone$ git branch -r
  rootbranch
  tku
  trunk

但是如果我使用 _git svn clone file:/ 克隆//tmp/gitsvn/svnrepo git-clone2 -bbranches//_,我只得到子分支:

/tmp/gitsvn/git-clone2$ git branch -r
  tku/subbranch

有没有办法同时拥有两者?

I am trying to use git svn to connect to our company repository. We have a slightly non-standard branches directory. How to access this using git svn has been discussed before, however, we seem to have a slight twist in our branch names that seems to keep me from getting them all.

Let's consider an example svn repo:

trunk/
tags/
branches/
    rootbranch/
    tku/subbranch

We have branches at the root level of the branches directory. But we have branches in nested folders, as well. The same goes for the tags dir, but I think that is just a second example of the same problem.

If I use git svn clone file:///tmp/gitsvn/svnrepo git-clone -s, I get only the root branches, as expected:

/tmp/gitsvn/git-clone$ git branch -r
  rootbranch
  tku
  trunk

But if I clone using _git svn clone file:///tmp/gitsvn/svnrepo git-clone2 -b branches//_, I get only the sub-branches:

/tmp/gitsvn/git-clone2$ git branch -r
  tku/subbranch

Is there a way to have both?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ι不睡觉的鱼゛ 2024-11-10 19:36:59

可以通过向 git-svn 配置添加多个分支行来访问其他分支。

.git/config 文件中,会有类似于以下内容的部分:

[svn-remote "svn"]
  url = http://server/svn
  fetch = trunk:refs/remotes/trunk
  branches = branches/*:refs/remotes/branches/*
  tags = tags/*:refs/remotes/tags/*

只需为分支的额外目录添加另一个条目即可。例如:

branches = branches/tku/*:refs/remotes/branches/tku/*

然后运行git svn fetch从svn存储库中检索分支。

我相信在构建 git 存储库时也可以使用克隆命令的多个 -b 选项来创建此设置。

git svn clone http://svn.foo.org/project -T trunk -b branches -b branches/tku -t tags

Additional branches can be accessed by adding multiple branches lines to the git-svn config.

In the .git/config file, there will be a section similar to the following:

[svn-remote "svn"]
  url = http://server/svn
  fetch = trunk:refs/remotes/trunk
  branches = branches/*:refs/remotes/branches/*
  tags = tags/*:refs/remotes/tags/*

Simply add another entry for the extra directory of branches. For example:

branches = branches/tku/*:refs/remotes/branches/tku/*

Then run git svn fetch to retrieve the branches from the svn repository.

I believe it's also possible to create this setup when constructing the git repository, using multiple -b options to the clone command.

git svn clone http://svn.foo.org/project -T trunk -b branches -b branches/tku -t tags
雨巷深深 2024-11-10 19:36:59

对于其他被这个问题绊倒的人来说:似乎两者兼而有之是不可能的。 Subversion 允许混合设置分支,但不鼓励这样做,因此 git 不支持这一点似乎也没关系。我的解决方案是将所有分支提升到同一级别,然后忘记该问题并继续前进。无论如何,只有一层分支似乎更好。

For anyone else who stumbles over this: it seems that having both is not possible. Subversion allows a mixed setup of branches, but it is discouraged, and so it seems okay that git does not support this. My solution was to bring all branches to the same level, then forget about the issue and move on. Having only one level of branches seems better anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文