无论我在将文件添加到排除文件之前还是之后创建文件,它都不会忽略它。
$: cat ./.git/info/exclude
/*.php
/license.txt
/wp-admin
/wp-includes
/wp-content/themes/impact/page-test.php
wp-content/themes/impact/page-test.php
page-test.php
$: git status
On branch development
Your branch is up-to-date with 'origin/development'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
wp-content/themes/impact/page-test.php
nothing added to commit but untracked files present (use "git add" to track)
答案 0 :(得分:1)
据我了解,/*.php
仅匹配顶级php文件。
如果要忽略所有php文件:
$: cat ./.git/info/exclude
*.php
代替
$: cat ./.git/info/exclude
/*.php
如果您要忽略某个目录中的php文件:
$: cat ./.git/info/exclude
/wp-content/**/*.php
答案 1 :(得分:1)
检查gitignore规则是否未在其他地方覆盖
使用git check-ignore -v <PATH>
列出影响PATH
忽略状态的最后一条规则。
文档中列出了应用gitignore规则的顺序:https://git-scm.com/docs/gitignore
$ HOME / .config / git / ignore,$ GIT_DIR / info / exclude,.gitignore
(第一个“全局gitignore”路径可能会用git config --global core.excludesfile
进行更改)
子文件夹中的.gitignore
文件可能会覆盖该文件夹及其子文件夹的规则...