Search code examples
gitignore

.gitignore doesn't ignores directories


I've got this .gitignore file:

[admin]/
[editor]/
[gamemodes]/
[gameplay]/
[managers]/
[web]/

But the git status shows that:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        [admin]/
        [editor]/
        [gamemodes]/
        [gameplay]/
        [managers]/
        [web]/
        editor_dump/
        editor_map_backups/
        editor_test/
        guieditor/

Why is it happening? Of course, I've got .gitignore in the right place.


Solution

  • It works fine for me if I escape the brackets.

    ls -a
    

    . .. .git .gitignore [admin]

    more .gitignore
    

    \[admin\]

     git status
    

    On branch master

    Initial commit

    Untracked files:
    (use "git add ..." to include in what will be committed)

    .gitignore

    The brackets are used to specify a range of characters. https://git-scm.com/docs/gitignore

    So if they're not escaped then you are essentially trying to match any one character a, d, m, i, n.