简体   繁体   English

获取任何版本的git存储库中的文件数

[英]Get number of files in git repository at any revision

I'd like to be able to find the number of files in a Git repository at a given revision, preferably without having to check out the revision first. 我希望能够在给定的版本中找到Git存储库中的文件数,最好不必先查看修订版。

I thought git ls-files might get me somewhere, but I'm not able to see any way of passing Git a revision for it. 我认为git ls-files可能会把我带到某个地方,但是我无法看到任何方式将Git传递给它。

Thanks in advance! 提前致谢!

ls-files operates on the index, which is by nature associated with the current checkout. ls-files对索引进行操作,索引本质上与当前签出相关联。 Use ls-tree , as in git ls-tree -r --name-only <tree-ish> . 使用ls-tree ,如git ls-tree -r --name-only <tree-ish> If you just want to count lines, using --name-only will speed things up by limiting the output. 如果你只想计算行数,使用--name-only将通过限制输出来加快速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM