Skip to content

Instantly share code, notes, and snippets.

@bundit
Created October 8, 2020 03:22
Show Gist options
  • Save bundit/4bc42a57f18b2ef455fd0a4376cd3c14 to your computer and use it in GitHub Desktop.
Save bundit/4bc42a57f18b2ef455fd0a4376cd3c14 to your computer and use it in GitHub Desktop.
Count lines of code a git tracked project
// Referenced from https://gist.github.com/mandiwise/dc53cb9da00856d7cdbb
// List line count of all tracked files
$ git ls-files | xargs wc -l
// Match only certain file-types
$ git ls-files -- '*.js*' | xargs wc -l
// Add additional file-types to count
$ git ls-files -- '*.js*' '*.jsx' '*.tsx' '*.css' | xargs wc -l
// Ignore file-types
$ git ls-files -- ':!:*.json' | xargs wc -l
// Only return total lines of code
$ git ls-files -- '*.js*' '*.jsx' '*.tsx' '*.css' ':!:*.json' | xargs cat | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment