计算 git 存储库中的行数 [英] Count number of lines in a git repository
本文介绍了计算 git 存储库中的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何计算 git 存储库中所有文件的总行数?
How would I count the total number of lines present in all the files in a git repository?
git ls-files
给我一个 git 跟踪的文件列表.
git ls-files
gives me a list of files tracked by git.
我正在寻找一个命令来cat
所有这些文件.类似的东西
I'm looking for a command to cat
all those files. Something like
git ls-files | [cat all these files] | wc -l
推荐答案
xargs
会让你 cat
将所有文件放在一起,然后将它们传递给 wc代码>,就像你问的:
xargs
will let you cat
all the files together before passing them to wc
, like you asked:
git ls-files | xargs cat | wc -l
但是跳过中间的 cat
可以为您提供更多信息并且可能更好:
But skipping the intermediate cat
gives you more information and is probably better:
git ls-files | xargs wc -l
这篇关于计算 git 存储库中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文