Subject: Re: Gitignore file exceptions are not applied to untarcked files

From: Anatoly Borodin <[email-masked]>
Date: Fri, 29 Jan 2016 20:54:30 +0000 (UTC)

Hi Junio,

I've tested it with many older versions of git, as well as with the recent
v2.7.0 - it seems like this feature has been never working properly.

The script https://gist.github.com/anatolyborodin/9c581b50c584534fff28

#!/bin/sh

set -e

# a
# b
# c
# D/a
# D/b
# D/c
# E/F/a
# E/F/b
# E/F/c

mkdir -p D E/F
touch a b c D/a D/b D/c E/F/a E/F/b E/F/c

echo && echo '.gitignore' && echo '----------'
echo '*\n!b\n!D/b\n!/D/b\n!/E/*/b' > .gitignore
cat .gitignore

echo && echo 'With `--ignored`' && echo '----------'
git status --ignored

echo && echo 'Without `--ignored`' && echo '----------'
git status

The output:

.gitignore
----------
*
!b
/D/b
!/D/b
!/E/*/b

With `--ignored`
----------
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        b

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

        .gitignore
        D/
        E/
        a
        c

nothing added to commit but untracked files present (use "git add" to track)

Without `--ignored`
----------
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        b

nothing added to commit but untracked files present (use "git add" to track)

All files in the subdirectories are ignored, no matter what.

-- 
Mit freundlichen Grüßen,
Anatoly Borodin