暂存文件的 Git 列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33610682/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git list of staged files
提问by Timon de Groot
I staged a lot of files using git add
, now I want to see all the files I have staged, without untrackedfiles or changed but unstagedfiles.
我使用 暂存了很多文件git add
,现在我想查看我暂存的所有文件,没有未跟踪的文件或已更改但未暂存的文件。
How do I do that? When using git diff --cached
I can see the changes of what I just staged. So then I tried using git status --cached
but that --cached
unfortunately doesn't work on git status
.
我怎么做?使用时git diff --cached
我可以看到我刚刚上演的内容的变化。然后我尝试使用,git status --cached
但--cached
不幸的是这不适用于git status
.
回答by Timon de Groot
The best way to do this is by running the command:
执行此操作的最佳方法是运行以下命令:
git diff --name-only --cached
When you check the manual you will likely find the following:
当您查看手册时,您可能会发现以下内容:
--name-only
Show only names of changed files.
And on the examplepart of the manual:
在手册的示例部分:
git diff --cached
Changes between the index and your last commit.
Combined together you get the changes between the index and your last commit
and Show only names of changed files.
结合在一起你得到changes between the index and your last commit
和Show only names of changed files.
Update: --staged
is also available as an alias for --cached
above in more recent git versions.
更新:在最近的 git 版本中--staged
也可以作为--cached
上面的别名使用。