Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to get total number of +/- ( Insertions and Deletions) from a single git commit

Tags:

git

github

I have a single git commit and would need to get the total number of insertions and deletions.

I know "git show <SHA>" is showing about details of my commit but I am not sure how to get total number of changes only from a particular commit.

git diff --stat <SHA1> <SHA2> also does't work because I should use only a single commit.

Kindly share me if you have any information.

like image 945
Giri lekkala Avatar asked Oct 17 '25 13:10

Giri lekkala


1 Answers

You should still be able to use git diff --stat:

git diff --stat <SHA>~ <SHA>
# or, for a global total only:
git diff --shortstat <SHA>~ <SHA>

The ~ refers to the direct parent of <SHA>. You are only using one <SHA>: the commit <SHA>, and its direct parent <SHA>~.

For example:

C:\Users\vonc\prog\git\git>git diff --stat e646ab9cf83025e1000db6ec3c1716f978b099f2~ e646ab9cf83025e1000db6ec3c1716f978b099f2
 po/TEAMS    |    8 +-
 po/ca.po    | 3949 ++++++++++++++++++++++++++++++-------------------------
 po/de.po    | 3776 +++++++++++++++++++++++++++++-----------------------
 po/fr.po    | 3746 +++++++++++++++++++++++++++++-----------------------
 po/git.pot  | 3547 +++++++++++++++++++++++++++----------------------
 po/sv.po    | 3723 +++++++++++++++++++++++++++++-----------------------
 po/vi.po    | 3762 +++++++++++++++++++++++++++++-----------------------
 po/zh_CN.po | 4217 +++++++++++++++++++++++++++++++++--------------------------
 8 files changed, 15007 insertions(+), 11721 deletions(-)

For just the total:

C:\Users\vonc\prog\git\git>git diff --shortstat e646ab9cf83025e1000db6ec3c1716f978b099f2~ e646ab9cf83025e1000db6ec3c1716f978b099f2
 8 files changed, 15007 insertions(+), 11721 deletions(-)
like image 197
VonC Avatar answered Oct 20 '25 04:10

VonC