.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).

  • What do ++ and +- mean in a Debian diff file?
  • Why does a merge need you to consider the common ancestor?
  • Reading git diff output
  • Unzip - how do I put inflated files into an array
  • Get a cumulative git diffs for multiple non-consecutuve commits
  • patches between diverging git forks
  • 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!

  • Git: Filtering commit history by branch
  • Should I clone a node library inside node_modules to modify it?
  • Is it possible to have all “git diff” commands use the “Python diff”, in all git projects?
  • Maven JGitFlow plugin authentication for HTTPS
  • Git asking for password on Gitosis from capifony
  • git, made a pull-request but found a bug in my code, how to fix it?
  • 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.