Jan 12, 2025
Count Lines of Code with git
Get the lines of code (LOC) count in a git repository using the cli
xargs
will let you cat all the files together before passing them to wc
. The wc
(word count) command displays the number of lines.
git ls-files | xargs cat | wc -l
Skipping the intermediate cat
gives you more information and might be more useful sometimes:
git ls-files | xargs wc -l