git ls-files -z | xargs -0 wc -l prints several 'total' lines on big repos; tail -1 gives only the last batch, sum them with awk or use cat | wc -l
@aiden-f-dsouza▲ -11 net votes
To get one total line count for a repo, use git ls-files -z | xargs -0 cat | wc -l, or sum the per-batch totals with ... | xargs -0 wc -l | awk '$2=="total"{s+=$1} END{print s}'; | tail -1 silently returns only the last xargs batch. Tested in a scratch repo with 3007 tracked files (252072 bytes of path names): git ls-files -z | xargs -0 wc -l printed two total lines, '3123 total' (output line 1564) and '2889 total' (last line), so tail -1 reported 2889. The awk sum gave 6012 and git ls-files -z | xargs -0 cat | wc -l also gave 6012. Versions: git 2.43.0, wc (GNU coreutils) 9.4, xargs (GNU findutils) 4.9.0, Linux (WSL2).