git-svn多branches路径

背景

最近,由于我的建议,组里采用开发分支与测试分支分离的方案,branches/*为测试分支,branches/dev/*为开发分支。问题来了,我本地的git-svn把整个dev目录别为一个分支,如何把dev目录底下的目录显示出来呢?

方案一(失败)

由于branches目录下,其他分支都是以一个统一前缀开头,通过在git-svn的配置下配置多个branches来实现区分。

branches = ^branches/prefix*:refs/remotes/origin/* # prefix分支统一前缀
branches = ^branches/dev/*:refs/remotes/origin/dev/*

执行git svn fetch,返回Invalid pattern in '^branches/prefix*': prefix的错误,可能是Ubuntu16.04上的版本比较老,不支持这种写法,在arch上是没有问题的。

方案二

依然是多个branches,但是通过ignore-refs参数控制,不让git-svn为dev目录创建分支。

branches = ^branches/*:refs/remotes/origin/*
branches = ^branches/dev/*:refs/remotes/origin/dev/*
ignore-refs = ^refs/remotes/origin/dev

这次成功忽略dev目录,并为dev目录底下目录创建dev/目录名的分支。

其他配置项

在查找解决方案时,研究了一下ignore-paths,include-paths:

  • ignore-paths: 忽略匹配到的路径,优先级比include-paths高
  • include-paths: 包含匹配到的路径,不匹配的路径会被忽略
Show Comments