How to calculate how many lines of code you deleted (or added) using git

What I learned today — 23 May 2018

Niel de Wet
1 min readMay 23, 2018

This is a bit manual, but I’m sure this can be automated more.

Step 1: Get the diff summary for each commit

git diff --compact-summary 35f1b50aa6de2aaf17ae6e906f8def7ba49970c7 a1494f98e27ded60319b79f70f4b442c0354040a | tail -1

For each commit, get the compact summary diff between the previous commit and your commit. The first commit hash is the older one.

115 files changed, 98 insertions(+), 6712 deletions(-)

Step 2: Add up the deletions (or insertions)

This is a bit manual, but some simple arithmetic is all you need.

--

--

No responses yet