如何让 Mercurial 忽略除 *.cs 文件之外的所有内容?
我启动了一个项目并将其添加到 Mercurial 中。但我只想将 *.cs
文件置于版本控制下。所以我必须添加 bin
、obj
、sln
、suo
、_resharper
文件夹等忽略模式。
如何让Hg只监控白名单等特定类型的文件?如何在 Subversion 中做到这一点?
I started a project and added it to Mercurial. But I want to take *.cs
file under version control only. So I have to add bin
, obj
, sln
, suo
, _resharper
folder etc to ignore pattern.
How to let Hg only monitor certain kind of file like white list? How to do that in Subversion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需在遇到扩展名时将其添加到您的
.hgignore
文件即可:等等。这并不是很多工作,并且它向世界其他地方准确记录了您认为对版本控制不重要的文件类型。
您甚至可以设置全局忽略文件,请参阅
忽略[ui]
部分 中的 code> 条目。尝试通过使用负向前瞻正则表达式和其他巫术来颠倒
.hgignore
(在我看来)不是一个好主意。它几乎肯定不会起作用,只会导致混乱。这是因为hg
将给定路径名称的所有前缀与.hgignore
中的规则。 类似的文件将被忽略
因此,如果其中任何一个与
.hgignore
文件中的规则匹配,则 。特别是,这意味着您不能使用负先行表达式来不忽略a/b/c.cs
——该规则将匹配a/b
或 <代码>a。Just add the extensions to your
.hgignore
file as you come across them:and so on. It's not a lot of work, and it documents to the rest of the world exactly what kind of files you consider unimportant for revision control.
You can even setup a global ignore file, please see the
ignore
entry in the[ui]
section.Trying to turn the
.hgignore
upside-down by using negative lookahead regular expressions and other voodoo is (in my opinion) not a good idea. It will almost surely not work and will only lead to confusion. This is becausehg
matches all prefixes of a give path name against the rules in.hgignore
. So a file likewill be ignored if any of
is matched by a rule in your
.hgignore
file. In particular, this means that you cannot use a negative lookahead expression to havea/b/c.cs
not-ignored -- the rule will matcha/b
ora
.关于 Martin Geisler 提供的 Mercurial 问题的链接 (https://www.mercurial-scm。 org/bts/issue712),请注意,该问题不是技术难题,而是支持:
Regarding the link to a Mercurial issue supplied by Martin Geisler (https://www.mercurial-scm.org/bts/issue712), please note that the issue is not one of technical difficulty, but support:
将包含这些内容的名为
.hgignore
的文件添加到您的存储库中。Subversion 不允许您使用正则表达式来忽略文件,仅允许使用 的子集glob 语法 来匹配文件/目录名称。我不知道如何忽略不以 .cs 结尾的文件,因此我搜索了网络和 此网页 说:
谨慎使用它:)
编辑:Martin Geisler 是对的,我错了,正则表达式语法是错误的。我道歉。正确的概念是存在的,但没有元字符......:(
Add a file named
.hgignore
to your repository with these contents.Subversion doesn't let you use regex to ignore files, only a subset of glob syntax to match file/directory names. I had no idea how to make ignore files not ending in .cs so I searched the web and this webpage says:
Use it with caution :)
Edit: Martin Geisler is right and I was mistaken, the regexp syntax is wrong. I apologize. The correct concept is there but not the metacharacters... :(