How to list all files tracked by Git excluding submodules?

bash, git

Solution

git grep --cached -l ''

lists all non-empty files, excluding both submodules and symlinks.

You may also be interested in excluding binary files for your mass refactorings: How to list all text (non-binary) files in a git repository?

Tested on Git 2.16.1 with this test repo.

Problem

``` git ls-files ``` also lists submodules. With: List submodules in a git repository and How to remove the lines which appear on file B from another file A? I can do: ``` git ls-files | grep -Fxvf <(git submodule status | cut -d' ' -f3) ``` or the more verbose and versatile: ``` git ls-files | while IFS='' read -r file; do if [ -f "$file" ]; then echo "$file" fi done ``` Is there a shorter way using some git command / flags?

Original source

Related problems