git 将 #*# glob 添加到 .gitignore?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2209810/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
add #*# glob to .gitignore?
提问by Steve Folly
I want to add emacs autosave files to my .gitignore with the glob #*#
but of course, lines starting with a hash are comment lines.
我想使用 glob 将 emacs 自动保存文件添加到我的 .gitignore 中,#*#
但当然,以哈希开头的行是注释行。
How can I get this into my .gitignore without it being treated as a comment?
如何在不将其视为评论的情况下将其放入我的 .gitignore 中?
回答by VonC
Did you try
你试过了吗
\#*#
Since 1.6.2, \
should be supported in .gitignore
(see this patch)
从 1.6.2 开始,\
应该支持.gitignore
(见这个补丁)
To be precise, 1.6.2.1(March 2009)
准确地说,1.6.2.1(2009 年 3 月)
.gitignore
learned to handle backslash as a quoting mechanism for comment introduction character "#
".
.gitignore
学会了处理反斜杠作为注释引入字符“#
”的引用机制。
回答by Charles Stewart
Another way of escaping #
is to use the character set syntax, so that your #*#
glob becomes
另一种转义方法#
是使用字符集语法,这样你的#*#
glob 就变成了
[#]*[#]
in your .gitignore
file.
在您的.gitignore
文件中。
回答by Ryan Fox
This doesn't exactly answer your question, but I think it may solve more problems than just this one symptom:
这并不能完全回答你的问题,但我认为它可以解决更多的问题,而不仅仅是这个症状:
You can move the autosave and backup filesinto a completely different directory so that your source directories don't get cluttered.
您可以将自动保存和备份文件移动到一个完全不同的目录中,这样您的源目录就不会变得混乱。
回答by cevaris
This worked for me.
这对我有用。
*[#]*[#]
*[#]*
@CharlesStewart was close but did not work for sub-directory files which had autosave generated files.
@CharlesStewart 很接近,但不适用于具有自动保存生成文件的子目录文件。