12 mercurial dvcs glob hgignore
我讨厌看到我的存储库中的每个目录列出每个文件两次,一次在前面有一个点,一次没有.我尝试添加.*
到我的.hgignore文件,但它没有任何效果.这是错误的语法,更重要的是,首先尝试这个是一个坏主意吗?谢谢.
Ry4*_*ase 18
你在gavinb的评论中得到了几乎正确的答案,但这场比赛有点广泛.然而,关于忽视面部的关键概念是由RogerPage提供的,再次在评论中(每个人都喜欢评论的答案是什么?).
我们来看看这九个文件:
dir.with.dots/file.with.dots
dir.with.dots/filewithoutdots
dir.with.dots/.filestartwithdot
dirwithoutdots/file.with.dots
dirwithoutdots/filewithoutdots
dirwithoutdots/.filestartwithdot
.startwithdot/file.with.dots
.startwithdot/filewithoutdots
.startwithdot/.filestartwithdot
Run Code Online (Sandbox Code Playgroud)
如果在hgignore的默认正则表达式模式下,您执行以下操作:
\..*
Run Code Online (Sandbox Code Playgroud)
你忽略了这9个文件中的8个:
$ hg stat -i
I .hgignore
I .startwithdot/.filestartwithdot
I .startwithdot/file.with.dots
I .startwithdot/filewithoutdots
I dir.with.dots/.filestartwithdot
I dir.with.dots/file.with.dots
I dir.with.dots/filewithoutdots
I dirwithoutdots/.filestartwithdot
I dirwithoutdots/file.with.dots
Run Code Online (Sandbox Code Playgroud)
这比你想要的更广泛.它忽略了任何地方都有点的东西.
要忽略所有文件和指南(不是你说的,但你想要的东西),以点开头,你使用这个正则表达式模式:
(^|/)\.
Run Code Online (Sandbox Code Playgroud)
它表示字面点之前的东西必须是line(^
)或斜线的开头.
$ hg stat -i
I .hgignore
I .startwithdot/.filestartwithdot
I .startwithdot/file.with.dots
I .startwithdot/filewithoutdots
I dir.with.dots/.filestartwithdot
I dirwithoutdots/.filestartwithdot
Run Code Online (Sandbox Code Playgroud)
这只捕获了以点开头的文件或目录.
然而,出现的另一个关键概念是.hgignore在添加文件后没有效果.它将阻止通过外卡添加,但您始终可以使用显式覆盖.hgignore hg add
.并且一旦添加了文件,就不再咨询hgignore.
这实际上非常方便,因为你可以广泛地忽略(例如.*\.jar
:)然后添加你想要手动的例外,而不必使用你的hgignore文件.但是,在这种情况下,它意味着您需要hg rm
意外添加的文件,而tonfa显示了如何执行此操作(只要文件名中没有空格).
最后,它听起来像你想要的.hgignore文件是:
(^|/)\._
Run Code Online (Sandbox Code Playgroud)
并且您需要删除已添加的内容:
find . -type f -name "._*" -print0 |xargs -0 hg rm
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4112 次 |
最近记录: |