.gitattributes not making a difference, trying to skip files when using git difftool

I’ve read the Git Pro website and I’ve read multiple answers on StackOverflow, but sadly I am simply unable to make .gitattributes work for me.

Whenever I’m using git difftool, it will attempt to display the difference between binary files, such as image files (PNG).

  • How to use `git diff --color-words` outside a Git repository?
  • Merging changesets in git for a code review
  • What does Git think a file's executable bit's value is?
  • Merge/diff tool that can show authors (supports blame or annotate) in files under version control
  • how to read index diff --git output
  • Diff in Emacs between version of file in working dir and previous commit in git repo
  • I have tried a variety of combinations in my .gitattributes file, but whenever I run my git difftool command, it still attempt to compare the binary files.

    In my repository’s folder, I have:
    [my project’s files subdirectories]

    I have tried many combinations of filters for my .gitattributes file. For example:

    *.pbxproj binary
    *.png binary

    Or also:

    *.pbxproj binary -diff
    *.png binary -diff


    *.pbxproj binary
    *.png binary
    *.pbxproj -diff -difftool
    *.png -diff -difftool

    Every time, I simply add my .gitattributes file to the index and commit it. However, after doing so, when I run my git difftool to examine my differences between two branches, this happens:

    git difftool otherBranch HEAD

    Viewing: ‘MyApp.xcodeproj/project.pbxproj’
    Hit return to launch ‘diffmerge’:

    Viewing: ‘MyApp/Background1.png’
    Hit return to launch ‘diffmerge’:

    How come it’s doing this? How can I finally set my .gitattributes file properly so I do not have to view the diffs for these specific files?

    To further investigate, I have used the git check-attr command as follows:
    git check-attr binary MyApp/MainBackground.png

    The output is MyApp/MainBackground.png: binary: set … I wonder why git difftool still forces me to view the diff!

  • Exceptions in .gitignore
  • Large 66GiB legacy CVS repo — it is a good idea to migrate to GIT or Mercurial?
  • How do I unlink my computer from a github account?
  • Is it possible to get commit logs/messages of a remote git repo without git clone
  • creating a repo in gitlab using CLI
  • git shows random files changed on Mac NFS filesystem
  • 2 Solutions collect form web for “.gitattributes not making a difference, trying to skip files when using git difftool”

    It looks like this is a deficiency in difftool. If you use the .gitattributes file as you have described then the output of ‘git diff’ is modified as intended so setting *.proj binary or *.proj -diff changes the git diff output for any .proj files to ‘binary files differ’. However, difftool apears never to look at the attributes. I believe this is because difftool basically calls the same code as mergetool and merging of binary files is supported (if only by copying one over the other). The attached patch is a small change to the difftool-helper script that should cause it to skip files for which the binary attribute is set. It is probably something for the git mailing list.

    --- git-difftool--helper    2011-06-03 21:48:08.000000000 +0100
    +++ /opt/git/libexec/git-core/git-difftool--helper  2011-10-06 13:17:55.000000000 +0100
    @@ -56,6 +56,10 @@
    +if test $(git check-attr diff "$1" | sed 's/.*diff: //') = 'unset'; then
    +   echo skip binary file "\"$1\""
     if ! use_ext_cmd; then
        if test -n "$GIT_DIFF_TOOL"; then
    @@ -70,3 +74,4 @@
        launch_merge_tool "$1" "$2" "$5"
        shift 7

    patthoyts’s answer worked for me.

    The trick for me was figuring out version of git-difftool--helper git was using (MacPorts had installed multiple versions)

    I used (with the difftool open):

    lsof | grep "git-difftool--helper"
    Git Baby is a git and github fan, let's start git clone.