git ls-tree输出的工作目录? [英] git ls-tree output of working directory?

查看:184
本文介绍了git ls-tree输出的工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来以与 ls-tree 相同的方式输出,但是我的工作目录。每当我运行 git ls-tree。时,它表示致命:不是有效的对象名称。

解决方案

git ls-tree 只适用于git refs,例如 ls-tree HEAD



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






正如你指出的那样, git ls-files -s 会列出索引中的文件(即文件在理论上,你可能会弄乱索引,运行 git ls-files -s ,然后尝试恢复它,例如

  git commit 
git add。
git ls-files -s
git reset。
git reset --soft HEAD ^

看起来正确,并且在一个简单的测试中工作,但可以吃掉所有的文件。


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 .

解决方案

git ls-tree only works with git refs, e.g. ls-tree HEAD.

Try git ls-files. You probably want the -s and/or -m flags.


As you point out, git ls-files -s will list the files in the index (i.e. files that have been staged).

In theory, you could mess with the index, run git ls-files -s, then try restore it, e.g.

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.

这篇关于git ls-tree输出的工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆