The history
https://stackoverflow.com/a/6718135/14972148
confusion: --cache vs --index etc.
From my modified man gitcli
:

add/index/stage/cache
The index file:
- is an index of all tracked files
- used as a staging area for commits
- contains cached SHA1 hashes for the files (speeds up performance)
From man git
:
$GIT_INDEX_FILE
sets the index file.
If not specified,
$GIT_DIR/index
is used.
The index file is a binary file.
When opened by nvim, here is part of the screenshot:

When opened by nvim with a plugin named fugitive
:

The content is very similar to
the output of git status
, instead of strings .git/index
related command
- git add ("a file is added/staged to the index")
- git restore --staged ( --staged | restore the index )
- git rm --cached (--cached | only remove files from the index )
stage vs track
- Untracked changes are not in Git.
- Unstaged changes are in Git, but not marked for commit.
- Staged changes are in Git and marked for commit.
git ls-files
1.
-c, --cached ( cache: obsolete for index)
Show cached files in the output
(default)
-s, --stage
Show staged (git add) files'
mode bits,
object name
stage number
-u, --unmerged
(forces --stage)
Show unmerged files in the output
-d, --deleted
-m, --modified
-k, --killed
Show files on the filesystem
that need to be removed due to
file/directory conflicts
for checkout-index to succeed.
2.
-o, --others
other (i.e. untracked) files
--directory
If a whole directory is classified as "other",
show just its name (with a trailing slash)
and not its whole contents.
--no-empty-directory
Do not list empty directories.
Has no effect without --directory.
Further Reading
https://github.blog/2021-11-10-make-your-monorepo-feel-small-with-gits-sparse-index/

