0

I'm assigned to a task to delete unnecessary files from our git repository. This results in deleting many files and editing few others. When I issue git show or git log -p my screen is flooded with the contents of the deleted files and I can hardly find the meaningful parts which are the modifications I made in the other files.

Illustration:

--- a/path/to/a/file
+++ /dev/null
@@ -1,41 +0,0 @@
-Lots of content I don't want to see.
-Lots of content I don't want to see.
-Lots of content I don't want to see.
-Lots of content I don't want to see.
-Lots of content I don't want to see.
-...

Is there any way to suppress displaying the contents of deleted files?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Notinlist
  • 16,144
  • 10
  • 57
  • 99
  • 1
    Separate deletion and modification into different revisions. – eftshift0 Aug 12 '20 at 15:25
  • @eftshift0 Not a bad idea. But deleting files and deleting the references from other files to them and committing these actions as one seems desirable for me. Registered your idea as a workaround :-) – Notinlist Aug 12 '20 at 16:03
  • 2
    You might do it the other way around: delete the references, then delete the files themselves. – eftshift0 Aug 12 '20 at 16:05

1 Answers1

0

A solution would be

git show 3764981273649817263498712 \
  | sed '/^\+\+\+ \/dev\/null/,/^diff/d' \
  | colordiff \
  | less -R

Note

If the output of git show is not interactive (piped to other command) then it will not be colored and a pager (like less) will not be invoked. Invoking colordiff and then less -R solves this problem.

Con

The output is not precise, but good enough for humans.

Notinlist
  • 16,144
  • 10
  • 57
  • 99