Is there a Bash script-like shorthand for matching multiple different extensions in a .gitignore
file such as:
*.{bak,save,aux,nav,toc}
?
The syntax above definitely does not work.
The method mentioned in the other answer, *[.bak, .save, .aux,. nav, .toc]
, does not work. Or at least, not as expected. It actually selects much more than just those extensions.
As far as I can tell, there is no way to do this, unless the extensions you want to ignore are all a single character long.
According to Git's documentation:
"
[]
" matches one character in a selected range
As can be seen in the example later on that page:
# ignore objects and archives, anywhere in the tree. *.[oa]
This would ignore any .o
or .a
files.
So this means that a pattern like *[.ext, .txt, .bin]
will behave identically to *[beintx., ]
(which is just the same pattern with duplicate characters removed and sorted) and will ignore any file ending in (including extension) any one of those nine characters.
I just tried this out on a Git repository of my own and it does indeed seem to follow this behavior.
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