I would like to list all files that are not ignored by .gitignore, ie all source files of my repository.
ag
does it well by default, but I\'m not aware of
Here is another way, using git check-ignore
which you may find it cleaner:
find . -type f
will give you all the files in the current folder.
find . -type f -not -path './.git/*'
will give you all the files, with the exception of everything in .git folder, which you definitely don't want to include. then,
for f in $(find . -type f -not -path './.git/*'); do echo $f; done
is the same as above. Just a preparation to the next step, which introduce the condition. The idea is to use the git check-ignore -q
which returns exit 0 when a path is ignored. Hence, here is the full command
for f in $(find . -type f -a -not -path './.git/*'); do
if ! $(git check-ignore -q $f); then echo $f; fi
done