.hgignore 似乎不起作用
我的项目根目录中有一个 .hgignore 文件,但它没有执行蹲下操作。当我执行 hg add
时,项目目录中的每个文件都会被添加和跟踪。无论我使用 tortoisehg 还是命令行,我都会得到相同的结果。命令行是我的偏好。这是怎么回事?
我的.hgignore
(取自SO上的另一个问题):
# use glob syntax
syntax: glob
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]humbs.db
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
*.resharper
I have a .hgignore
file in my project's root directory and it's not doing squat. When I do an hg add
, every single file in my project directory is being added and tracked. I get the same result whether I use tortoisehg or the command-line. Command-line is my preference. What's going on here?
My .hgignore
(taken from another question on SO):
# use glob syntax
syntax: glob
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]humbs.db
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
*.resharper
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
显然这是文件编码的问题。我正在 Notepad++ 中编辑该文件(尝试了 ANSI 和 UTF-8 编码),并且该文件在编辑时看起来很好。我已经放弃并决定使用命令
notepad .hgignore
重新开始。然后我粘贴了给我带来麻烦的文件内容,所有内容都在一行上,没有中断。我修复了中断,保存了文件,它立即起作用了。我仍然不确定为什么该文件在 Notepad++ 中看起来很好,但实际上却输出了垃圾。
Apparently it was some issue with the encoding of the file. I was editing the file in Notepad++ (tried ANSI and UTF-8 encodings) and the file looked fine when editing. I had given up and decided to start over by using the command
notepad .hgignore
. Then I pasted the contents from the file that was giving me trouble and everything was on a single line with no breaks. I fixed the breaks, saved the file and it immediately worked.I'm still not sure why the file looked fine in Notepad++ but was actually putting out garbage.
glob
匹配语法考虑了路径。您可以切换到syntax:relglob
作为相对路径名,或者在您的模式中添加**/
前缀。The
glob
match syntax takes the path into account. You can switch tosyntax: relglob
for relative pathnames or prefix your patterns with**/
.您可能需要告诉 Mercurial 全局忽略文件所在的位置。我必须在
.hgrc
的[ui]
部分添加此行才能正常工作。You may need to tell mercurial where the global ignore file is located. I had to add this line under the
[ui]
section of my.hgrc
for it to work.