Reputation: 45
I want to ignore files without exclamation marks. I think that the regular expression is *[!.]*
, but this ignores folders names too. Does .gitignore
have a folder/file marker?
Upvotes: 0
Views: 72
Reputation: 2409
First, !
is a special character in regexp. So you should use it with \
if you want to use !
as just a character. And your regexp has some other bugs. Your regexp should be *\!*
To recognize folders, you can use /
at the end. And to unignore file/folder, you can use the prefix !
at the front.
Finally, your .gitignore file should be
*\!*
!*\!*/
Upvotes: 0
Reputation: 5760
A folder in .gitignore ends with a /
. I tried to use your expression, but I did not get it to work. But the following entries seem to do the trick:
# Ignore Everything
*
# Unignore all files with extensions
!*.*
# Unignore all folders
!*/
So when you have these files:
a
a.txt
b/a
b/a.txt
the files a and b/a get ignored.
Upvotes: 1