zap*_*ing 8 regex git ignore git-svn
我试图做一个git-svn克隆将SVN中的所有文件导入GIT.给出的命令就是这个;
git svn clone --stdlayout --ignore-paths='(/cache|/tmps|/file/conf/setting.xml)' --authors-file=../authors.txt file:///svnFolder/local-repos/PRG PRG.git
Run Code Online (Sandbox Code Playgroud)
上面的克隆但问题是它忽略了所有具有缓存和tmps的文件和文件夹.比如它甚至忽略了这些
new/folder/cache
meta/files/sets/tmps.html
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我设置正则表达式,在忽略路径中忽略根文件夹的缓存和tmps目录中的文件和子目录.
小智 12
你的忽略路径正则表达式太笼统了.提供的正则表达式在完整路径上运行.例如,如果您的存储库布局是:
svn_root/path/to/your_project
Run Code Online (Sandbox Code Playgroud)
然后有一个标准的主干,分支和标签布局,一组被评估的样本路径行可能是:
svn_root/path/to/your_project/trunk/new/folder/cache
svn_root/path/to/your_project/trunk/meta/files/sets/tmps.html
svn_root/path/to/your_project/trunk/file/conf/setting.xml
svn_root/path/to/your_project/trunk/cache/...
svn_root/path/to/your_project/trunk/tmps/...
Run Code Online (Sandbox Code Playgroud)
让我们首先分析你提供的正则表达式作为ignore-paths参数的一部分:
'(/cache|/tmps|/file/conf/setting.xml)'
Run Code Online (Sandbox Code Playgroud)
在分析了正则表达式后,让我们使用您的表达式遍历上面给出的示例路径:
要评估的字符串:
svn_root/path/to/your_project/trunk/new/folder/cache
Run Code Online (Sandbox Code Playgroud)
要评估的字符串:
svn_root/path/to/your_project/trunk/meta/files/sets/tmps.html
Run Code Online (Sandbox Code Playgroud)
要评估的字符串:
svn_root/path/to/your_project/trunk/file/conf/setting.xml
Run Code Online (Sandbox Code Playgroud)
从这里,您可以看到为什么以下两个也被忽略.其中一个子表达式匹配每个路径的一部分:
svn_root/path/to/your_project/trunk/cache/...
svn_root/path/to/your_project/trunk/tmps/...
Run Code Online (Sandbox Code Playgroud)
有几种方法可以解决这个问题,但是如果你只想忽略trunk中的几个特定目录,你可以修改你的表达式,如下所示:
'(trunk/cache|trunk/tmps|/file/conf/setting\.xml)'
Run Code Online (Sandbox Code Playgroud)
这实际上取决于您想要做什么,您想要忽略哪些特定路径.如果您需要更多帮助,可以详细说明存储库的布局方式以及要忽略的目录.