Count number of lines in a git repository

后端 未结 16 2657
被撕碎了的回忆
被撕碎了的回忆 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:00

    I use the following:

    git grep ^ | wc -l
    

    This searches all files versioned by git for the regex ^, which represents the beginning of a line, so this command gives the total number of lines!

提交回复
热议问题