add #*# glob to .gitignore?

GitGitignore

Git Problem Overview


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 Solutions


Solution 1 - Git

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

Solution 2 - Git

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

 [#]*[#] 

in your .gitignore file.

Solution 3 - Git

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.

Solution 4 - Git

This worked for me.

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

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSteve FollyView Question on Stackoverflow
Solution 1 - GitVonCView Answer on Stackoverflow
Solution 2 - GitCharles StewartView Answer on Stackoverflow
Solution 3 - GitRyan FoxView Answer on Stackoverflow
Solution 4 - GitcevarisView Answer on Stackoverflow