Skip to content

How to count lines of code in a Git repo?#

Nothing bad in knowing how many lines of code or text out there in your repo. You don't even need your VCS to convey this analytics. All you need is git, grep and wc.

# count lines in .py and .robot files in /nuage-cats dir of the repo
$ git ls-files nuage-cats/ | grep -E ".*(py|robot)" | xargs wc -l
       0 nuage-cats/robot_lib/
     817 nuage-cats/robot_lib/lib/
     409 nuage-cats/robot_lib/lib/
    1841 nuage-cats/robot_lib/lib/
    2964 nuage-cats/robot_lib/lib/
      26 nuage-cats/test_suites/0910_fail_bridges_kvm_vms/0910_fail_bridges_kvm_vms.robot
   13636 total