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.
Depending on whether or not you want to include binary files, there are two solutions.
git grep --cached -al '' | xargs -P 4 cat | wc -lgit grep --cached -Il '' | xargs -P 4 cat | wc -l
"xargs -P 4" means it can read the files using four parallel processes. This can be really helpful if you are scanning very large repositories. Depending on capacity of the machine you may increase number of processes.
-a, process binary files as text (Include Binary)
-l '', show only filenames instead of matching lines (Scan only non empty files)
-I, don't match patterns in binary files (Exclude Binary)
--cached, search in index instead of in the work tree (Include uncommitted files)