Search notes:

git ls-files

git ls-files shows information about files in the index (the .git/index file) and the working tree.

Introductionary example

Initialize (git init) Create a repository for this example …
git  init  --quiet   repo
cd   repo
Github repository about-git, path: /commands/ls-files/intro/init-repo.ps1
… and create a directory and some files:
$null = mkdir dir-1

'foo'               >  foo.txt
'bar'               >  bar.txt
'abc'               >  dir-1/abc.txt
Github repository about-git, path: /commands/ls-files/intro/create-initial-files.ps1
Add the files to the index (git add):
git add *
Github repository about-git, path: /commands/ls-files/intro/add-initial-files.ps1
Add another file and modify foo.txt, but without adding them to the index
'FOO'               >  foo.txt
'baz'               >  baz.txt
Github repository about-git, path: /commands/ls-files/intro/create-more-files.ps1
git ls-index without further command line options shows the files in the index.
git ls-files
Github repository about-git, path: /commands/ls-files/intro/ls-files.ps1
Using the command line option -m shows files that are in the index and whose content in the working tree are different:
git ls-files -m
Github repository about-git, path: /commands/ls-files/intro/ls-files-m.ps1
The command line option -o shows «other» files, that is: files which are present in the working tree but not in the index:
git ls-files -o
Github repository about-git, path: /commands/ls-files/intro/ls-files-o.ps1
Commit the content of the index:
git commit --quiet -m "added some files"
Github repository about-git, path: /commands/ls-files/intro/commit-1.ps1
Remove a file from the index and the working tree (git rm) and another file from the working tree only.
git rm --quiet  bar.txt
    rm          dir-1/abc.txt
Github repository about-git, path: /commands/ls-files/intro/rm.ps1
Then use -d to show deleted files:
git ls-files -d
Github repository about-git, path: /commands/ls-files/intro/ls-files-d.ps1

See also

git mktree
git ls-tree
git commands

Index