Is there a way to stat the total number of lines added/removed/modified in a git repository? A number of posts give answers for "how many loc is this project at at a certain commit" by analyzing the files in it, it doesn't give a feel for just how many different things have been tried and abandoned and changed during the whole life of the project. And just checking out every single commit and stating that and summing that wouldn't make sense either, because there's usually quite a bit of redundancy from commit to commit.
-
Since you don't want one of the obvious behaviors, it may help for you to search for an algorithm that does what you want and use that. In general, it's hard to give a definition of what constitutes a meaningful change, which seems to be what you're asking for here.– bk2204Apr 15, 2020 at 23:35
Add a comment
|
1 Answer
Can't think of something at a repo level but the following can work at a branch level:
Option 1:
git diff --shortstat $(git rev-list --max-parents=0 HEAD) @
Example output:
9 files changed, 273 insertions(+), 4 deletions(-)
or
git diff --numstat $(git rev-list --max-parents=0 HEAD) @
Example output (detailed by line insertions and line deletions per file):
10 4 rest-api.ps1 => auditlog.ps1
15 0 azlabshow.ps1
34 0 create-pr.ps1
26 0 get-build-time.ps1
25 0 getchangesets.ps1
42 0 listreleases.ps1
40 0 listusers-csv.ps1
43 0 merge-refs.ps1
38 0 testplans(outcome).ps1
Used git diff by diffing HEAD (@) with the initial commit. Use bash.