18

I have a mercurial repo with .hgignore file. I want to remove all files from disk (hg remove) in this repo which match pattern(s) listed in .hgignore.

I can list all ignored files with hg status -i but I don't know how can I delete them.

.hgignore contents:

syntax: glob

build
\.egg*
*.pyc

.DS_Store
*.sublime-*
4

2 回答 2

34

您只能hg remove在被跟踪的文件上运行。要删除与模式匹配的跟踪文件.hgignore,请运行此命令

$ hg forget "set:hgignore() and not ignored()"

这使用文件集来选择正确的文件。

如果要删除已被 Mercurial 忽略(未跟踪)的文件,请查看清除扩展名。这可用于清理工作副本,使其看起来像一个新的结帐。

于 2013-11-07T02:09:23.270 回答
3

hgrc help

一个更好的例子可能是:

purge = !$HG status --no-status --unknown -0 | xargs -0 rm

这将使 hg purge 以与清除扩展相同的方式删除存储库中的所有未知文件。

为了删除被忽略的文件而不是未知文件(“hg help status”),请使用--ignored| -i选项而不是--unknown

于 2013-11-06T21:12:13.617 回答