Show all ignored files in git

I'm having problems with git ls-files --others --ignored --exclude-standardnot listing some ignored files.

My project has this directory structure

.
├── aspnet
│   ├── .gitignore
│   ├── __init__.py
│   ├── lib
│   │   ├── <lots of big stuff>

aspnet/.gitignorelists lib/*and git add aspnet/lib/fooreports that this path is ignored.

But git ls-files --others --ignored --exclude-standarddoes not list files under lib. These are not verified files; they appear on the output if I do git ls-files --others, but not if I provide an ignored flag.

Using git version 1.7.9.5

Edit: works as expected with git version 1.8.5.2 (Apple Git -48), it seems to be a git error

+4
source share
3 answers

find (, UNIX/Linux), git:

find . -type f  | git check-ignore --stdin

find . -type f , git check-ignore , .gitignore.


check-ignore . .git , , POSIX (, bash, sh, dash, zsh). , .gitignore , . glob .gitignore, :

while read glob ; do
    if [ -d "$glob" ] ; then
        # Be aware of the fact that even out of an ignored 
        # folder a file could have been added using git add -f 
        find "$glob" -type f -exec \
            bash -c "FILE={};[ \$(git status -s \$FILE) == "" ] && echo \$FILE" \;
    else
        for file in "$glob" ; do
            # Again, be aware of files which add been added using -f
            bash -c "FILE={};[ \$(git status -s \$FILE) == "" ] && echo \$FILE" \;
        done
    fi
# Pipe stderr to /dev/null since .gitignore might contain entries for non 
# existing files which would trigger an error message when passing them to find
done < .gitignore 2>/dev/null | sort
+10

My Kung-Fu

find . -type d | grep -v .git | awk '{print $1"/"}' | git check-ignore -v --stdin
+2

Doing this in Windows PowerShell is simple:

PS> Get-ChildItem -Recurse | Select-Object Fullname | git check-ignore --stdin -v

The output looks pretty cool, as if it were designed for Cygwin or bash, which I do not use, so this may be my own wrong configuration, but it really helps to find out why this file is ignored.

Comments are based on git 2.22.0.windows.1

0
source

Source: https://habr.com/ru/post/1547493/


All Articles