Mark
Mark

Reputation: 6484

Does gitignore support regexp

How to make $HOME/.gitignore understand regexp? Specifically, I want to enable it ignore files modules.builtin and modules.order:

modules.\(order\|builtin)

This doesn't seem to be picked up when I'm running git status What am I doing wrong here?

Thanks.

Upvotes: 6

Views: 5503

Answers (2)

Anshul Goyal
Anshul Goyal

Reputation: 76997

No, gitignore doesn't support regexes, it only supports unix fnmatch style patterns.

You can read more about this on the git-scm entry for gitignore.

If you have multiple directories/files to ignore, you could try using modules.* as a single entry, or two entries as suggested by the other answer.

Upvotes: 7

IanPudney
IanPudney

Reputation: 6031

No, gitignore does not support full regular expressions. In your particular case, you can just put two lines:

modules.order
modules.builtin

However, I imagine you want to do a bit more. Gitignore does support some pattern matching; you can find the full documentation here, under "pattern format."

Upvotes: 1

Related Questions