Git索引究竟包含什么,以及我可以使用什么命令来查看索引的内容?
更新
谢谢你的所有答案.我知道索引充当临时区域,提交的内容是索引而不是工作树.我只是对索引对象的内容感到好奇.我想它可能是文件名/目录名列表,SHA-1对,也许是一种虚拟树?
在Git术语中,是否有任何可用于列出索引内容的管道命令?
我是git的新手,我正在研究git.
我在git中添加了一些文件:
git add <file1>
git add <file2>
Run Code Online (Sandbox Code Playgroud)
然后我想推动审查,但我错了
git commit
Run Code Online (Sandbox Code Playgroud)
所以我改变的文件不用于评论.
现在,如果我输入命令:
git status
Run Code Online (Sandbox Code Playgroud)
它说
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)
我想恢复该提交,我想推送这些文件进行审核而不是提交.谁能让我知道我怎么能这样做?
我试图从以下几个教程步骤中重现:
https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout
这是为 git 2.25 制作的,但现在在 2.27 中,运行时什么也没有发生:
$ git sparse-checkout set client/android
Run Code Online (Sandbox Code Playgroud)
我找不到让它工作的方法。
这是一个 MWE:
$ git clone --no-checkout https://github.com/derrickstolee/sparse-checkout-example
Cloning into 'sparse-checkout-example'...
$ cd sparse-checkout-example/
$ git sparse-checkout init --cone
Run Code Online (Sandbox Code Playgroud)
使用 git 2.25,我获得了一个非空目录:
$ ls -a
. .. bootstrap.sh LICENSE.md README.md .git
Run Code Online (Sandbox Code Playgroud)
使用 git 2.27,我获得了一个空目录:
$ ls -a
. .. .git
Run Code Online (Sandbox Code Playgroud)