Petruza
Petruza

Reputation: 12256

.git/info/exclude not excluding an untracked file

No matter if I create the file before or after adding it to the exclude file, it never ignores it.

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

Upvotes: 2

Views: 1634

Answers (2)

petrpulc
petrpulc

Reputation: 970

Check if the gitignore rule is not overwritten elsewhere

Use git check-ignore -v <PATH> to list the last rule that affects the ignore status of the PATH.

The order of applied gitignore rules is listed in documentation: https://git-scm.com/docs/gitignore

$HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore

(the first "global gitignore" path may be changed with git config --global core.excludesfile)

And the .gitignore file in subfolder may overwrite the rules for such folder and its subfolders...

Upvotes: 2

TobiSH
TobiSH

Reputation: 2921

As far as I understand it /*.php matches only toplevel php-files.

If you want to ignore all php files:

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

Instead of

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

If you want to ignore php-file in a certain dir:

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

Upvotes: 1

Related Questions