Suppressing differences for deleted files in git

I want to get a brief overview of local changes in my repository, but I do not need a diff that shows the deleted files, since each separate line is minus.

Basically, I want something like 'git diff HEAD <list of modified files only>' . In an ideal world, it will be preceded by a list of deleted and added files, but not show the differences between them.

I was mainly due to writing a utility that does this:

 git diff HEAD `git status | grep modified | cut -d : -f 2` 

when I was wondering if there is any git -y way to do this. Is there a flag that I am missing? I would also like to keep the color output.

+51
git shell
Sep 11 '10 at 18:35
source share
4 answers

In Git versions 1.8.4 and earlier, you can do this with --diff-filter and specifying everything except the β€œD” criterion (deleted):

 $ git diff --diff-filter = ACMRTUXB

In Git versions 1.8.5 and later, the ability to exclude files matching the specified criteria was added, which greatly simplifies this task. You can exclude using lowercase rather than uppercase letters. Like this:

 $ git diff --diff-filter = d
+74
Sep 11 '10 at
source share

Almost the same answer as posted by Dan Moulding , but you probably want to indicate that you don't like it , but for hidden deleted files it will be:

 git diff --diff-filter=d 
+23
Jan 20 '17 at 21:32
source share

git diff (-D|--irreversible-delete) will omit the diff body for deleted files. I do not think there is an equivalent for added files.

+22
Mar 13 '13 at 1:06 on
source share

You can also use -M, which try to find files that have been moved

 git diff -M -D 

more can get more information: git diff --help (the -B option may also be interesting)

+1
Nov 10 '16 at 7:12
source share



All Articles