How to list versioned files in git?

送分小仙女□ 提交于 2019-12-20 09:29:03

问题


I would like to list the versioned files in the root directory of a git repository. To do the same thing in bazaar, you run:

bzr ls --versioned --non-recursive

How do I do this in git?


回答1:


It would be more helpful if you described exactly what listing you want to show. Guessing from the bzr document, I imagine that you want something like this.

git ls-tree --name-only HEAD

This lists the names of files in the current directory which are currently in the HEAD revision, which should be close to what you are asking for.




回答2:


I do not know what "bzr ls --versioned --non-recursive" does, but I suspect that it is either

  • "git ls-tree --name-only HEAD" (like Charles Bailey wrote), which lists files at given revision, and by default is non-recursive

or

  • "git ls-files" (perhaps additionally with --cached and --exclude-standard options), which lists specified kinds of files (by default it is files that are in index), and is recursive (and currently there is no way to turn off being recursive, as far as I know).


来源:https://stackoverflow.com/questions/1441317/how-to-list-versioned-files-in-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!