使用 git-svn 访问混合分支文件夹布局
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以通过向 git-svn 配置添加多个分支行来访问其他分支。
在 .git/config 文件中,会有类似于以下内容的部分:
只需为分支的额外目录添加另一个条目即可。例如:
然后运行git svn fetch从svn存储库中检索分支。
我相信在构建 git 存储库时也可以使用克隆命令的多个 -b 选项来创建此设置。
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:
Simply add another entry for the extra directory of branches. For example:
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.
对于其他被这个问题绊倒的人来说:似乎两者兼而有之是不可能的。 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.