Finding a file in Git

Find a file in working directory

# Find 'a.c' in the current directory and its subdirectories.
$ git ls-files -- '**/a.c' a.c
a.c
source/a.c

Find a file in staging area

# Find 'a.c' in the current directory of staging area
# --cached, show files in the staging area
$ git ls-files --cached -- '**/a.c' a.c

Find a file in a commit

It also shows whether a file is tracked or not in a commit.

# Find 'a.c' in the current directory of HEAD commit
# -r, recursely
# --name-only, list file names (including path) only
$ git ls-tree -r --name-only HEAD | grep a.c
a.c
source/a.c

Command git ls-tree -r --name-only <commit> lists all files in a specific commit.