工作目录的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:45:01  来源:igfitidea点击:

git ls-tree output of working directory?

git

提问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-treeonly 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 -sand/or -mflags.

试试git ls-files。您可能需要-s和/或-m标志。



As you point out, git ls-files -swill 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.

看起来是对的,并在一个简单的测试中工作,但可能会吃掉你所有的文件。