All through an example:
mkdir cdiff && cd cdiff git init cat text.txt # first comment 1 2 # midle comment 3 4 # last comment git add test.txt git commit -m 'first' Now let's change it in the working directory:
cat test.txt 1 2 3 # first comment # last comment 4 bye Create a utility:
cat /usr/local/bin/git-cdiff #!/bin/sh diff --color -u <(grep -Ev '^(#|$)' $1) <(git show $2:$1 | grep -Ev '^(#|$)') chmod 555 /usr/local/bin/git-cdiff Compare the same file from a specific commit with one in working directory:
git cdiff test.txt HEAD Or:
git cdiff test.txt <hash commit> The files are identical. Change the file in the working directory:
echo byegit >>cdiff test.txt a4ec1 git--- cdiff/dev/fd/63 test 2021-07-09 08:09:48.txt581153921 a4ec1+0300 5d4+++ /dev/fd/62 2021-07-09 08:09:48.581153921 +0300 <@@ -1,4 +1,4 @@ 1 2 +3 4 -bye