1

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.

1
  • 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.
    – bk2204
    Apr 15, 2020 at 23:35

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.