Count number of lines in a git repository

后端 未结 16 2650
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 03:17

How would I count the total number of lines present in all the files in a git repository?

git ls-files gives me a list of files tracked by git.

16条回答
  •  情话喂你
    2020-12-02 04:06

    I was playing around with cmder (http://gooseberrycreative.com/cmder/) and I wanted to count the lines of html,css,java and javascript. While some of the answers above worked, or pattern in grep didn't - I found here (https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns) that I had to escape it

    So this is what I use now:

    git ls-files | grep "\(.html\|.css\|.js\|.java\)$" | xargs wc -l

提交回复
热议问题