git - 如何 git svn 只获取具有特定模式的分支/标签?

标签 git git-svn git-branch

我想使用 git-svn 检查 Boost 库,我只想检查从 1.35 版本开始的主干和标签,即 tags/release/Boost_1_35 及以上。我的配置如下所示:

[svn-remote "svn"]
    ignore-paths = ^tags/release/(?i:(?!boost)|[^/]*(?:beta|rc)|boost_(?:0|1_[1-2]|1_3[0-4]))[^/]*/
    url = https://svn.boost.org/svn/boost
    fetch = trunk:refs/remotes/svn/trunk
    tags = tags/release/*:refs/remotes/svn/tags/*

但是,git fetch 仍然会获取大量不相关的标签,例如 svn/tags/version_0-9-10 或 svn/tags/version_0-9-10@44215。我想知道指定忽略路径以实现此效果的正确方法是什么。

顺便说一句:我读过How do I fetch/clone only a few branches using git-svn?但听起来不是可扩展的解决方案。

最佳答案

我已经设法对某些分支这样做了,但是由于 svn 中的标签实际上是分支,所以它应该是相同的:

在使用“-t 标签和 -b 分支”进行 git svn init 之后,我将 .git/config 编辑为:

[svn-remote "svn"]
        ... url, fetch and stuff ... 
        branches = branches/rel-2.1/*:refs/remotes/svn/branches/rel-2.1/*
        branches = branches/rel-2.2/*:refs/remotes/svn/branches/rel-2.2/*
        branches = branches/rel-2.3/*:refs/remotes/svn/branches/rel-2.3/*
        branches = branches/rel-2.4/*:refs/remotes/svn/branches/rel-2.4/*
        branches = branches/rel-2.5/*:refs/remotes/svn/branches/rel-2.5/*

我使用了一个简单的 python 代码来生成相关行并将其复制到 .git/config:

for x in range(1,6):
   print branches = "     branches/rel-2.{0}/*:refs/remotes/svn/branches/rel-2.{0}/*".format(x)

不如正则表达式可扩展,但这是我能找到的最好的。

关于git - 如何 git svn 只获取具有特定模式的分支/标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6915418/

相关文章:

git - 将多个 git 仓库 merge 为一个,保留分支历史

git - 如何在 Rust git2 中获取 `git checkout ...` 的行为

git - Vagrant 测试 Chef Recipe - 但如何处理私有(private) git

git - 如何在循环中运行 svn update 以将提交导入到 git?

svn - Git SVN 和外部

git - 如何将文件夹中的所有文件推送到所有git分支

git 提交并推送到分支但不 pull 请求

git - 以下未跟踪的工作树文件将被 merge : . gitignore 覆盖 请在 merge 之前移动或删除它们

Git svn 克隆 : How to defer fetch of revision history

Git:使用来自不同远程的两个具有相同名称的分支