gitgit-diffgit-pathspec

Excluding files from git-diff


I am tracking a project with Git. There are some Xcode project files in the working copy that I want to keep tracking, but I do not want to see in diffs, because there are always dozens of changed lines that I am never interested in. Is there a simple way to have git-diff(1) skip these files?

I’ve tried to set up a custom “silent” diff tool:

$ cat .gitattributes
Project.xcodeproj/* diff=nodiff

$ cat ~/.gitconfig
[diff "nodiff"]
    command = /bin/true

But:

$ git diff
external diff died, stopping at Project.xcodeproj/zoul.mode1v3.

What am I doing wrong?


Solution

  • The problem is that /bin/true will return immediately without reading its input. git diff therefore thinks, quite reasonably, that it has died prematurely.

    You really want to unset the diff attribute, not set it to a bogus command. Try this in your .gitattributes:

    Project.xcodeproj/* -diff