Introductionary example
git init --quiet repo
cd repo
… and create a directory and some files:
$null = mkdir dir-1
'foo' > foo.txt
'bar' > bar.txt
'abc' > dir-1/abc.txt
Add the files to the
index (
git add
):
git add *
Add another file and modify foo.txt
, but without adding them to the index
'FOO' > foo.txt
'baz' > baz.txt
git ls-index
without further command line options shows the files in the index.
git ls-files
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
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
Commit the content of the index:
git commit --quiet -m "added some files"
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
Then use -d
to show deleted files:
git ls-files -d