How to git svn fetch only branches/tags with certain patterns?

穿精又带淫゛_ 提交于 2019-12-21 20:22:03

问题


I want to check out Boost library using git-svn, and I only want to checkout trunk and tags starting from version 1.35, i.e. tags/release/Boost_1_35 and up. My config looks like this:

[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/*

However, git fetch still fetches tons of unrelated tags such as svn/tags/version_0-9-10 or svn/tags/version_0-9-10@44215. I wonder what's the correct way of specifying ignore-paths to achieve this effect.

BTW: I've read How do I fetch/clone only a few branches using git-svn? but doesn't sounds a scalable solution.


回答1:


I have managed to do so for certain branches, but since tags in svn are actually branches it should probably be the same:

After git svn init with "-t tags and -b branches" I have edited .git/config to be:

[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/*

I used a simple python code to generate the relevant lines and copied it to .git/config:

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

Not as scalable as regex, but that's the best I could find.



来源:https://stackoverflow.com/questions/6915418/how-to-git-svn-fetch-only-branches-tags-with-certain-patterns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!