我很惊讶 .gitignore 文件中的 *.user 之类的简单模式似乎与文件和文件夹名称匹配。
ringods$ mkdir TestIgnore
ringods$ cd TestIgnore/
ringods$ git init
Initialized empty Git repository in /Users/ringods/Projects/hostbasket/TestIgnore/.git/
ringods$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
ringods$ mkdir security.user
ringods$ touch security.user/file_may_not_be_ignored.txt
ringods$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# security.user/
nothing added to commit but untracked files present (use "git add" to track)
ringods$ echo "*.user"> .gitignore
ringods$ cat .gitignore
*.user
ringods$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
nothing added to commit but untracked files present (use "git add" to track)
我有错误的期望吗?如何编写带有扩展名 blah 的简单忽略文件并防止匹配以.blah结尾的文件夹?
gitignore手册页提到没有 / 的模式使用 shell glob 模式功能进行匹配,但它并没有真正告诉我它是仅匹配文件还是匹配文件和目录。