March 11, 2021 • 2 min read
Our engineering manager has asked us about the total number of lines on several repositories of the company. How can we find out that information?
We are going to use the command git ls-files and pipe its output towc using xargs .
npx superplate-cli my-app
cd my-app
git ls-files to recursively see all the files versioned in the repo.git ls-files
# .babelrc
# .eslintignore
# .eslintrc
# .gitattributes
# ...
git ls-files to wc using xargs .git ls-files | xargs wc
# 1 4 30 .babelrc
# 1 2 26 .eslintignore
# 25 37 600 .eslintrc
# 1 2 12 .gitattributes
# ...
# 25891 49458 1219057 total
Here we see:
And in the last row, information on the total of files.
So our repo has 25891 lines.