Search code examples
regexgitgitignore

.gitignore - ignore file starting with ~


To ignore any file starting with ~(tilde), I put following in gitignore file

^~.*

But, it is not working for the file name starting with ~(eg. ~$ofession email.docx).

There is no issue with gitignore configuration setting as other patterns are working well.

What is wrong here with the regular expression?


Solution

  • Regular expressions are not supported in .gitignore, you can use globs only. To fix it, use ~*, that will ignore anything starts with tilde.