OMBD#13: Find Out the Total Number of Lines on a Git Repository
Welcome to issue #13 of One Minute Better Developer, where you become a more successful software developer by reading short nuggets of knowledge, one minute at a time.
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?
- As a repository example, we are going to create a new project using superplate.
npx superplate-cli my-app
2. Once created, we are going into the repo directory.
3. Now we can run
git ls-files to recursively see all the files versioned in the repo.
git ls-files# .babelrc
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:
- 1st column: number of lines in that file.
- 2nd column: number of words in that file.
- 3rd column: number of characters in that file.
And in the last row, information on the total of files.
So our repo has 25891 lines.
If you liked this story, you may also like:
1 Minute To Become A Better Developer (#12)
Learn how to leverage window.IntersectionObserver to find out how many visitors see your content, in one minute.
1 Minute To Become A Better Developer (#15)
Learn how to remove all your node_modules directories, in one minute.