【问题标题】:Why my hgignore does not appear to work?为什么我的 hgignore 似乎不起作用?
【发布时间】:2012-10-19 11:10:49
【问题描述】:

当我做hg status 时,我看到了:

[jiewmeng@JM Code]$ hg status
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/SPA.lib
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/UnitTesting.exe
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/UnitTesting.ilk
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/UnitTesting.pdb
M examples/SampleTestingSolution/EmptyGeneralTesting/EmptyGeneralTesting.suo
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/AST.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/CL.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/CL.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/DesignExtractor.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Lib-link.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Lib-link.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Node.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/PKB.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Parser.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Query Evaluator.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Query Processor.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.Build.CppClean.log
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.lastbuildstate
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.log
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/VarTable.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/cl.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/lib.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/vc100.idb
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/vc100.pdb
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/SPA.vcxproj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/SPA.vcxproj.filters
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/CL.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/CL.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/NodeTest.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTest.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTesting.lastbuildstate
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTesting.log
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/cl.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/link.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/link.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/link.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/mt.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/mt.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/mt.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/vc100.idb
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/vc100.pdb
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/source/UnitTest.cpp
M examples/SampleTestingSolution/EmptyGeneralTesting/source/Parser.cpp
M examples/SampleTestingSolution/EmptyGeneralTesting/source/Parser.h
A .hgignore
? examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.write.1.tlog
? examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Parser.h
? examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTesting.write.1.tlog

所以我让.hgignore 看起来像

syntax: glob

*.lib
*.tlog
*.log
*.obj
*.tlog
*.idb
*.pdb
*.exe
*.ilk
*.filters

当我再次执行 hg status 时,我看到输出有类似/不明显的差异。为什么?我希望所有这些都会从hg status

【问题讨论】:

  • 当我遇到这样的事情时,我使用 procmon (www.systeminternals.com) 检查使用了哪些文件以及程序如何搜索它们。它通常比搜索文档、设置等更快。

标签: mercurial


【解决方案1】:

如果您已经添加了这些文件,则需要在应用 hgignore 指令之前“hg forget”它们。
请参阅“What is the difference between hg forget and hg remove?”:hg remove -Af(即hg forget)将删除它们而不将它们从工作目录中删除。
另见this thread

未跟踪的文件会在“hg status”中显示一个问号,除非它们与 .hgignore 文件匹配。

【讨论】:

  • 好吧,我真的不明白忘记或删除实际上做了什么,删除会删除文件吗?我知道forgetremove -Af 的简写?我做了remove -Afhg status 现在给出了类似的输出,除了行前面带有R。文件似乎没有被删除,但它们会从 repo 中删除吗?
  • 尝试提交,然后再次 hg 状态...返回到类似的输出?在那些线的前面。它们应该与我的 .hgignore 匹配?
  • @JiewMeng hg forgethg remove -Af 的快捷方式,它可以在将文件保存在磁盘上的同时取消跟踪文件。 hg status 应该用 '?' 显示它,除非你的 .hgignore 匹配那个未跟踪的文件(在这种情况下,hg status 根本不会显示它)
  • @JiewMeng 查看boredzo.org/blog/archives/2008-03-20/… 的示例。将 .hgignore 放在 repo 的根目录中。 (mercurial.selenic.com/wiki/.hgignorestackoverflow.com/a/4965250/6309
  • @JiewMeng 您是否添加了.hgignore 文件? (stackoverflow.com/questions/3472866/…)。你不需要为 hgignore 添加它来工作,但如果它确实有效,你应该添加它并提交它 (stackoverflow.com/a/965344/6309)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-14
  • 2010-10-14
  • 2022-11-13
  • 2022-12-11
  • 1970-01-01
  • 2018-06-09
相关资源
最近更新 更多