Skip to content

Instantly share code, notes, and snippets.

@thevangelist
Last active April 24, 2025 13:25
Show Gist options
  • Save thevangelist/48cc0855bc6df50f16edf6d282b172cc to your computer and use it in GitHub Desktop.
Save thevangelist/48cc0855bc6df50f16edf6d282b172cc to your computer and use it in GitHub Desktop.
Git diff --stat with exclude files

// Just the exclude diff lines changed

git log --author="$(git config user.email)" --pretty=tformat: --numstat -- ':!package-lock.json' |
awk '
  NF == 3 {
    inserted += $1;
    deleted += $2;
  }
  END {
    delta = inserted - deleted;
    ratio = (deleted == 0 || inserted == 0) ? "∞" : sprintf("%.2f", deleted / inserted);
    printf "Commit stats:\n";
    printf "- Lines added (total)....  %d\n", inserted;
    printf "- Lines deleted (total)..  %d\n", deleted;
    printf "- Total lines (delta)....  %d\n", delta;
    printf "- Add./Del. ratio (1:n)..  1 : %s\n", ratio;
  }
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment