在 Git 中,暂存区也称为索引。似乎要说的是,当您在工作目录中进行更改并将这些更改添加到“暂存”时,git 会将这些文件添加到索引文件中。打开项目 /.git/index 文件时,我看到一个文件,其中包含在我键入时显示的文本:
git status
我可能会得到如下所示的输出:
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Gemfile
#
no changes added to commit (use "git add" and/or "git commit -a")
但在Git Index Contents等其他地方,他们通过键入以下内容来表示:
git ls-files --stage
您可以看到索引的内容.. 虽然这显然不是 /.git/index 中的内容。.git 目录中的哪个文件实际上包含该索引?我怀疑,我可能错了.. .git/index 将更改信息存储在“已修改”行中,然后在输入 git ls-files --stage 时,它正在建立一个文件列表根据工作目录中的文件以及在此索引文件中列为已修改的文件进行暂存及其哈希值。这是正确的吗?