I want to get a quick overview of the local changes in my repository, but I don't want a diff that shows deleted files, since every single line is a minus.
Basically, I want something like 'git diff HEAD <list of modified files only>'
. In an ideal world, it would be preceded by the list of deleted and added files, but not show the diffs within them.
I was most of the way through writing a utility that does this:
git diff HEAD `git status | grep modified | cut -d : -f 2`
when I wondered if there was some git-y way to do it instead. Is there a flag I'm missing? I'd love to preserve the color output, too.
You can use git diff --name-status, that will show you files that where added, modified and deleted.
Git keeps a log of all the changes made to files within a repository. You can restore a file that you have deleted since a previous commit by using the git checkout command. This command lets you navigate to a previous point in your repository's history.
Add All Files using Git Add. The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area.
git diff --cached: It shows only those changes of tracked files which are present in staging area. git diff HEAD: It shows all changes of tracked files which are present in working directory and staging area.
In Git versions 1.8.5 and newer, you can do this using the --diff-filter
option and specifying "d" (lowercase) to tell it to exclude deleted files.
$ git diff --diff-filter=d
In Git versions older than 1.8.5, you can do this with the --diff-filter
option and specifying all but the "D" (deleted) criteria:
$ git diff --diff-filter=ACMRTUXB
git diff -D
(or equivalently git diff --irreversible-delete
) will omit the diff body for deleted files. I don't think there's an equivalent for added files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With