5
我很驚訝像。* .user這樣的簡單模式似乎與文件和文件夾名稱匹配.gitignore文件。如何gitignore *只*文件?
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 man page提到沒有使用shell glob模式功能匹配模式,但它並沒有真正地告訴我它是否僅匹配文件或文件和目錄。