.gitignore不忽略目录

时间:2020-04-16 12:10:37

标签: gitignore

我有这个.gitignore文件:

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

但是git status显示:

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/

为什么会这样?当然,我把.gitignore放在正确的位置。

2 个答案:

答案 0 :(得分:2)

如果我逃脱了括号,对我来说效果很好。

ls -a

。 .. .git .gitignore [admin]

more .gitignore

\ [admin \]

 git status

在分支母版上

初始提交

未跟踪的文件:
(使用“ git add ...”将要提交的内容包括在内)

.gitignore

括号用于指定字符范围。 https://git-scm.com/docs/gitignore

因此,如果它们没有被转义,那么您实际上是在尝试匹配任何一个字符a,d,m,i,n。

答案 1 :(得分:0)

我已经做了类似的事情:

# ignore everything
*

# but not fp_ scripts
!fp_*

# ...and other
!.gitignore
!README.md

现在一切正常。仍然知道为什么旧的.gitignore无法正常工作。