I've got some temp files that are named:
#myfile#
.#anotherfile
./some/dir/#myfile#
./somewhere/.#anotherfile
I tried adding the (to me) obvious pattern, see command below
cat >> .gitignore <<EOF
#.*
.*#.*
EOF
but git status still lists the files.
I realized that the hash '#' symbol is the comment character, so I tried quoting it, and added:
\#.*
.*\#.*
But that didn't work either.
Searches for it didn't give me an answer, but did make me realize that git doesn't use normal regular expression syntax so my guesses were not valid for git.
Some good searches were
git ignore filenames which contain - This doesn't address how to handle the hash # comment character
add #*# glob to .gitignore? - This fixed one of them.
My .gitignore now has:
\#*#
.\#*#
I now just have the one pattern that needs fixing:
./somewhere/.#anotherfile