.hgignore 目录“_notes”整个存储库树?

发布于 2024-08-29 00:38:24 字数 187 浏览 12 评论 0原文

我想忽略整个存储库中的所有目录“_notes”。 _notes是由dreamweaver生成的,不是项目本身的一部分,但这些目录分散在整个项目中。

不知何故 ^_notes$ 没有在 .hgignore 中完成这项工作...我是否必须将 .hgignore 定向到每个目录“_notes”还是递归地执行此操作?

我不太确定手册页

I want to ignore all directories "_notes" throughout a repository. _notes is generated by dreamweaver and is not part of the project itself, but these directories are scattered throughout the project.

Somehow ^_notes$ is not doing the job in .hgignore ... Do I have to direct .hgignore to each and every directory "_notes" or does it do it recursively?

I am not quite sure about the man pages

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

少年亿悲伤 2024-09-05 00:38:24

尝试:

syntax: glob
_notes/*

我可能应该提到,如果已经添加了目录,则不能忽略它们。如果您使用的是较新的 Mercurial 版本,请使用 hg忘记,就是这种情况。

Try:

syntax: glob
_notes/*

I should probably mention that if the directories have already been added you cannot ignore them. Use hg forget if you are on a newer Mercurial version, be this the case.

錯遇了你 2024-09-05 00:38:24

.hgignore

syntax: glob
_notes

这不是特定于目录的,因此如果您有任何具有该确切名称的文件,它们也将被忽略。

例子:

$ hg init subu && cd subu
$ mkdir _notes
$ mkdir a && mkdir a/_notes
$ echo 'syntax: glob' >>.hgignore
$ echo '_notes' >>.hgignore
$ touch file.txt
$ touch _notes/file.txt
$ touch a/file.txt
$ touch a/_notes/file.txt
$ hg st -A
? .hgignore
? a/file.txt
? file.txt
I _notes/file.txt
I a/_notes/file.txt

.hgignore

syntax: glob
_notes

This isn't specific to directories, so if you have any files with that exact name, they will be ignored too.

Example:

$ hg init subu && cd subu
$ mkdir _notes
$ mkdir a && mkdir a/_notes
$ echo 'syntax: glob' >>.hgignore
$ echo '_notes' >>.hgignore
$ touch file.txt
$ touch _notes/file.txt
$ touch a/file.txt
$ touch a/_notes/file.txt
$ hg st -A
? .hgignore
? a/file.txt
? file.txt
I _notes/file.txt
I a/_notes/file.txt
情深已缘浅 2024-09-05 00:38:24

正如您的评论所揭示的那样,您无法使其工作的原因是存储库中已经存在的优先级高于 .hgignore。 (想象一下,如果 .hgignore 优先,可能会出现令人讨厌的问题!弄乱正则表达式,您可能会停止跟踪一半的存储库)

要从存储库中删除内容,您可以使用 hg removehg忘记(这是 hg remove -Af 的别名)。您可能想要使用 hgforget 因为这会将其从存储库中删除,但不会删除本地副本; hg remove 也会(不带 -Af)删除本地副本

As your comment reveals, the reason you can't get it to work is that already being in the repository takes precedence over .hgignore. (Imagine the nasty issues that could arise if .hgignore took precedence! Mess up a regexp and you might stop tracking half your repo)

To remove stuff from the repo you can use hg remove or hg forget (which is an alias for hg remove -Af). You probably want to use hg forget as this will remove it from the repository but not delete the local copy; hg remove will (without -Af) delete the local copy as well

野の 2024-09-05 00:38:24

这将完成这项工作:

语法:regexp
/_notes/

如果您想检查存储库忽略了哪些文件,您可以尝试:
hg stat -i

这将列出 hg 通过 .hgignore 成功忽略的所有文件,这对于在向存储库添加任何内容之前进行调试非常有用。

!之前添加到存储库的文件将不会被忽略!

This will do the job:

syntax: regexp
/_notes/

In case you want to check what files are being ignored by your repository, you can try:
hg stat -i

This will list all files that are successfully ignored by hg through .hgignore, it is nice for debugging before you add anything to the repository.

!Previously added files to the repository will not be ignored!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文