Reputation: 26918
Putting
syntax:regexp
*.foo.[a-z]{1,4}
in .gitignore
does not work. I remember seeing
syntax:glob
and
syntax:regexp
some time ago in some .gitignore
files, but I couldn't file such syntax in Git manual. Is there a way to use regular regex in .gitignore
?
Upvotes: 0
Views: 413
Reputation: 174662
You are confusing .hgignore
with .gitignore
.
There is no such thing as a "normal file name extension"; what you can do to start off with is to add the following:
**/foo.*
**/
will match foo.*
in all directories.
.gitignore
uses the shell glob syntax:
Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname.
Upvotes: 2
Reputation: 240314
Without using any regex syntax that might or might not be supported (I don't see any evidence for it either), you could get the same behavior with four rules:
*.foo.[a-z]
*.foo.[a-z][a-z]
*.foo.[a-z][a-z][a-z]
*.foo.[a-z][a-z][a-z][a-z]
If you wanted to compromise slightly, you could use *.foo.?*
(anything ending in foo, a dot, and at least one more character), or *.foo.[a-z]*
(anything ending in foo and then an extension that starts off alphabetic).
Upvotes: 3