git 如何获取git存储库中所有文件的数量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9468970/
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
How to get a count of all the files in a git repository?
提问by Dan Rigby
How would you get a count of all the files currently in a git repository?
您将如何获得当前在 git 存储库中的所有文件的数量?
回答by Dan Rigby
You can get a count of all tracked files in a git respository by using the following command:
您可以使用以下命令获取 git 存储库中所有跟踪文件的计数:
git ls-files | wc -l
Command Breakdown:
命令分解:
- The
git ls-files
command by itself prints out a list of all the tracked files in the repository, one per line. - The
|
operator funnels the output from the preceding command into the command following the pipe. - The
wc -l
command calls the word count (wc) program. Passing the-l
flag asks it to return the total number of lines.
- 该
git ls-files
命令本身会打印出存储库中所有跟踪文件的列表,每行一个。 - 的
|
操作者漏斗前述命令输出到命令管道以下。 - 该
wc -l
命令调用字数统计 (wc) 程序。传递-l
标志要求它返回总行数。
Note:This returns a count of only the trackedfiles in the repository meaning that any ignored files or new & uncommitted files will not be counted.
注意:这仅返回存储库中跟踪文件的计数,这意味着不会计算任何被忽略的文件或新的和未提交的文件。
回答by user40176
If you came here looking for a way to do this for a repo hosted on github without cloning it, you can do this:
如果您来到这里寻找一种方法来为托管在 github 上的存储库执行此操作而无需克隆它,您可以这样做:
svn ls -R https://github.com/exampleproject/branches/master | wc -l