I'm currently trying to add gitignore to a json file that sits inside of two bracketed folders and one regular folder. I have tried multiple things to gitignore the file but it doesn't seem to work.
I've only been able to gitignore one bracketed file, is there a way to ignore a file that sits within multiple bracketed folders? [paid-resources]/[snipes]/plants/plants.json
CodePudding user response:
[
and ]
are special characters in .gitignore
as they're part of fnmatch/glob
syntax; see the section File Name Patterns in man sh
. As they're special they must be escaped to be used literally. So try this pattern in .gitignore
:
**/\[*\]/\[*\]/*
**
start in any subdirectory;
\[
, \]
— interpret [
and ]
literally;
/\[*\]/\[*\]/
— two "bracketed" directories, one inside the other