powershell - 使用 hg purge 时排除目录

标签 powershell version-control mercurial teamcity purge

我正在尝试在我的存储库中执行 hg 清除,但我需要从该清除中排除一些目录(例如 node_modules 和其他内容)。

基本上,我想保留(而不是删除)这些目录,以避免每次都重新下载它们。

这是关于我的构建过程,它在开始新的构建过程之前运行 hg purge 并因此删除所有被忽略的东西(在 .hgignore 中列出)。我不希望这种情况发生在 node_modules 和其他一些目录上。

有没有办法告诉 Mercurial 不要对某些目录进行清除?

最佳答案

使用-X/--exclude命令行开关(可以指定多次):

hg purge -X 'glob:node_modules/**.js'

上述模式忽略了 node_modules 目录中的所有 Javascript 文件,包括子目录中的文件。使用 /** 匹配目录下的所有内容:

hg purge -X 'glob:node_modules/**'

参见 File names and pattern matching chapter在 Mercurial 指南中;那里描述的模式都可以在这里使用。

当测试你的模式时,确保你使用 --print 命令行选项到 hg purge,然后它只会打印 将删除哪些文件。这有助于迭代您的模式,您不必在两次尝试之间不断重新设置文件。

关于powershell - 使用 hg purge 时排除目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35061186/

相关文章:

html - 将表格的线条涂成红色

git - 在 VCS 中使 shell 提示符显示当前头部

Mercurial:包括预提交更改的文件

mercurial - 内部 Vrs 子存储库的外部路径

powershell - 使用 Powershell 的经典计算机的 Azure 计费

powershell - 如何从 Switch 语句中退出 While 循环

powershell - PowerShell 中的 VBscript 公共(public)属性设置/获取等效项

Git:如何 rebase 到过去的特定提交?

git - 如何重新 merge 在 github 中还原的提交?

mercurial - Mercurial Rebase 可以删除分支吗?