bashgitgrep

Git - show with just file name and differences


I'd like to show results of git show in such way that it lists filenames and changes only, without other data, like this:

filename-1.txt
+Line added

filename-2.txt
+Line added
-Line removed

If it's not possible with git alone, grep etc are also ok.


Solution

  • git show accepts the same options as git log:

    # --format="" : display no information about the commit
    # -U0 : display diff with no context lines
    git show --format="" -U0 <commit-ish>
    

    If you really want to get rid of all the extra lines (@@ -43,2 +45,7 @@, --- a/that/file, +++ b/that/file ...), you will need some scripting on the output.