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?
You have the option to use double Asterisk (**) to match any number of directories and files. For example, Test/**/*. txt will tell git to ignore only files ending with . txt in the test directory and its subdirectories.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
git folder is ignored by default. All others are deamed potentially important for the source-base unless configured otherwise within the repository or at a global level.
You may escape a character by surrounding it with "[]":
[~][$]*
This will ignore any Microsoft temporary/backup files.
Regular expressions are not supported in .gitignore
, you can use globs only. To fix it, use ~*
, that will ignore anything starts with tilde.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With