I want to suppress all the output for files in
dir/*
when using the command
git diff
I decided to follow the suggestions from
Excluding files from git-diff
Method 1.
Adding to .git/config
[alias]
mydiff = !git diff -- $(git diff --name-only | grep -Ev "dir/")
and using
git mydiff
worked as expected and thus solved my problem. However, I wanted to use Method 2.
Method 2.
Adding to .gitattributes
dir/* -diff
and then using
git diff
Produces the output
diff --git a/dir/1 b/dir/1
deleted file mode 100644
index 05e9130..0000000
...
Question
How to suppress this undesired output for all the files in dir/?
The reason you see output with your settings is that
dir/* -diffonly marks files indiras binary files, so text diff would not apply to them (seeman 5 gitattributes).To suppress any output for files in
diryou have to define an external diff driver like this:Assign new “silent” (you can choose your name) diff driver:
Define “silent” diff function:
That should do the trick.