把“球”加到“吉蒂诺尔”上?

我要将 emacs 自动保存文件添加到。但是当然,以散列开头的行是注释行。

我怎样才能把它放进我的. gitignore 而不被当作一个注释呢?

16378 次浏览

Did you try

\#*#

Since 1.6.2, \ should be supported in .gitignore (see this patch)

To be precise, 1.6.2.1 (March 2009)

.gitignore learned to handle backslash as a quoting mechanism for comment introduction character "#".

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 files into a completely different directory so that your source directories don't get cluttered.

Another way of escaping # is to use the character set syntax, so that your #*# glob becomes

 [#]*[#]

in your .gitignore file.

This worked for me.

*[#]*[#]
*[#]*

@CharlesStewart was close but did not work for sub-directory files which had autosave generated files.