add #*# glob to .gitignore?

2019-01-21 18:27发布

I want to add emacs autosave files to my .gitignore with the glob #*# but of course, lines starting with a hash are comment lines.

How can I get this into my .gitignore without it being treated as a comment?

标签: git gitignore
4条回答
smile是对你的礼貌
2楼-- · 2019-01-21 18:40

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 "#".

查看更多
地球回转人心会变
3楼-- · 2019-01-21 18:42

This worked for me.

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

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

查看更多
爷的心禁止访问
4楼-- · 2019-01-21 18:45

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

 [#]*[#] 

in your .gitignore file.

查看更多
你好瞎i
5楼-- · 2019-01-21 18:58

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.

查看更多
登录 后发表回答