Count number of lines in a git repository

Question

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.

I'm looking for a command to cat all those files. Something like

git ls-files | [cat all these files] | wc -l

Answer

xargs will let you cat all the files together before passing them to wc, like you asked:

git ls-files | xargs cat | wc -l

But skipping the intermediate cat gives you more information and is probably better:

git ls-files | xargs wc -l

What does each of the [y,n,q,a,d,/,K,j,J,g,e,?] stand for in context of git -p

What is the difference between git clone and checkout?