.git/info/exclude 不排除未跟踪的文件



无论我在将文件添加到排除文件之前还是之后创建文件,它都不会忽略它。

$: 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)

检查 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文件可能会覆盖此类文件夹及其子文件夹的规则......

据我了解,/*.php只匹配顶级php文件。

如果要忽略所有 php 文件:

$: cat ./.git/info/exclude
*.php

而不是

$: cat ./.git/info/exclude
/*.php

如果你想忽略某个目录中的php文件:

$: cat ./.git/info/exclude
/wp-content/**/*.php

最新更新