工作目录的 git ls-tree 输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10082514/
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 ls-tree output of working directory?
提问by Alexander Bird
I am looking for a way to have output in the same manner as ls-tree
, but of my working directory. Whenever I run git ls-tree .
it says fatal: Not a valid object name .
我正在寻找一种以与ls-tree
,相同的方式输出的方法,但是我的工作目录。每当我运行git ls-tree .
它说fatal: Not a valid object name .
回答by Mikel
git ls-tree
only works with git refs, e.g. ls-tree HEAD
.
git ls-tree
仅适用于 git refs,例如ls-tree HEAD
.
Try git ls-files
. You probably want the -s
and/or -m
flags.
试试git ls-files
。您可能需要-s
和/或-m
标志。
As you point out, git ls-files -s
will list the files in the index (i.e. files that have been staged).
正如您所指出的,git ls-files -s
将列出索引中的文件(即已暂存的文件)。
In theory, you could mess with the index, run git ls-files -s
, then try restore it, e.g.
理论上,你可以弄乱索引,运行git ls-files -s
,然后尝试恢复它,例如
git commit
git add .
git ls-files -s
git reset .
git reset --soft HEAD^
Seems right, and worked in a simple test, but could eat all your files.
看起来是对的,并在一个简单的测试中工作,但可能会吃掉你所有的文件。