.gitignore 不会忽略目录
.gitignore doesn't ignores directories
我有这个 .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。
如果我转义括号,对我来说效果很好。
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
中括号用于指定字符范围。 https://git-scm.com/docs/gitignore
因此,如果它们没有转义,那么您实际上是在尝试匹配任何一个字符 a、d、m、i、n。
我做过这样的事情:
# ignore everything
*
# but not fp_ scripts
!fp_*
# ...and other
!.gitignore
!README.md
现在一切正常。仍然不知道为什么旧 .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。
如果我转义括号,对我来说效果很好。
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
中括号用于指定字符范围。 https://git-scm.com/docs/gitignore
因此,如果它们没有转义,那么您实际上是在尝试匹配任何一个字符 a、d、m、i、n。
我做过这样的事情:
# ignore everything
*
# but not fp_ scripts
!fp_*
# ...and other
!.gitignore
!README.md
现在一切正常。仍然不知道为什么旧 .gitignore
不起作用。