简体   繁体   中英

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

I want to check out Boost library using git-svn, and I only want to checkout trunk and tags starting from version 1.35, ie 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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