简体   繁体   中英

.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?

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

You may escape a character by surrounding it with "[]":

[~][$]*

This will ignore any Microsoft temporary/backup files.

^~.* is ignoring only files that only begin with ~. eg "~.txt" or "~.docx".

Change it to ^~*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM