I have a file in my git repo that has never been comitted or added with
git add
. But .gitignore doesn't seem to work. This file is called
bit_train_[3].json
No previous commits contain this file. In my .gitignore (same folder as this file) I added the line
bit_train_[3].json
If I use git status -u
it says
Untracked files: bit_train_[3].json
Why is this file still visible?
I suspect that the brackets [3]
in the file name might cause the issue but I'm unsure
There are other .json files that I want to keep in my repos so I can't use *.json
in my gitignore
Square brackets are special characters — they mean character lists and ranges. To make git
interpret them literally in .gitignore
escape them with backslashes:
bit_train_\[3\].json