首页 > 解决方案 > .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)

标签: gitgitignoreignore

解决方案


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


推荐阅读