Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git diff --numstat with --name-status

Tags:

git

git-diff

Is there any way to get the output of running git diff --numstat and git diff --name-status combined in one run?
My problem is that if I am using only --numstat then I don't know whether there were just added some new lines to a file or if the file is completely new. When using --name-status I get the information if the file is new or not but the stats about the line modifications are missing.

Currently my workaround is running both commands separately and then merging that output by a PowerShell script but as the repo is rather big I would like to have the needed output in the first place. Thanks in advance for any help!

like image 799
DAXaholic Avatar asked Feb 17 '16 09:02

DAXaholic


1 Answers

you can combine the --numstat and the --summary flags;

git diff --numstat --summary

Note that a new file cannot be in the "unstaged" area; so suppose you used "git add" and "git rm", then your git status will look like this:

# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   b
#       deleted:    a

then using

git diff --cached --numstat --summary

will give you:

540  0   b
0    3   a
 create mode 100644 b
 delete mode 100644 a

NOTE : you can use the --numstat and the --summary flags in combination with git diff, git diff --cached, git show and probably other commands.

like image 141
Chris Maes Avatar answered Oct 23 '22 17:10

Chris Maes