You can get a count of all tracked files in a git respository by using the following command:
git ls-files | wc -l
Command Breakdown:
- The
git ls-files
command by itself prints out a list of all the tracked files in the repository, one per line. - The
|
operator funnels the output from the preceding command into the command following the pipe. - The
wc -l
command calls the word count (wc) program. Passing the-l
flag asks it to return the total number of lines.
Note: This returns a count of only the tracked files in the repository meaning that any ignored files or new & uncommitted files will not be counted.