Since regex is not effective in the .gitignore file, how can a glob encompass filenames such as the above?

1 Answer 1


.gitignore uses glob expressions on each line, so when you enter Editor1CurrentlyOpen[1].txt it will try to match Editor1CurrentlyOpen1.txt.

Add backslashes to mask the brackets in the entry:

  • 1
    One can remove the special meaning of '?', '' and'[' by preceding them by a backslash, or, in case this is part of a shell command line, enclosing them in quotes. Between brackets these characters stand for themselves. Thus, "[[?*]" matches the four charac- ters '[', '?', '' and '\'. Ah! found the manpages entry for that. (unix.com/man-page/Linux/7/glob) . It had been me trying to write regexes which was both entertaining and frustrating. Now I have to figure out how to automate the .gitignore to add those slashes. Sep 19, 2016 at 2:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .