Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to diff your .sketch files in Git

Using sketchtool to diff your .sketch files using text

Requirements

You need to have SketchTool installed somewhere in your path.

Setup

Add this in your ~/.gitconfig file (for some reason, it won't work in a local .gitconfig file):

[diff "sketchtool"]
  textconv = "sketchtool dump"
  cachetextconv = true
  binary = true

and then add this in your local or global .gitattributes file:

*.sketch diff=sketchtool

Usage

Now, whenever you modify a .sketch file in your repo, running git diff will produce a nice text diff like this:

screenshot 2015-11-16 09 15 50

@ZevEisenberg

This comment has been minimized.

ZevEisenberg commented Mar 2, 2016

This trick only worked for me with a project-local .gitattributes file, not a global one. Not sure why. @bomberstudios thanks for the tip!

@adoyle-h

This comment has been minimized.

adoyle-h commented Aug 4, 2016

@ZevEisenberg You should set core.attributesfile in the global gitconfig file. Like this:

[core]
    attributesfile = ~/.gitattributes

You could also run the command git config --global core.attributesfile ~/.gitattributes to set the path for your global gitattributes file.

@seehadley

This comment has been minimized.

seehadley commented Sep 13, 2016

Thanks for sharing this. One thing I've run into is many changes that appear to be unrelated to the change I made. In fact, to test this out I just changed the border radius on a single rectangle and can't find the change in the tool. Any suggestions?

@milsanore

This comment has been minimized.

milsanore commented Mar 10, 2017

Has anyone been able to achieve the same in SourceTree?

@AndyDentFree

This comment has been minimized.

AndyDentFree commented Nov 19, 2018

This works for me in Sourcetree 2.7.6. I put the absolute path of sketchtool in my ~/.gitconfig and added a single-line .gitattributes file as per above, directly in the repo. Now in SourceTree, instead of seeing a comparison of the bitmap preview of the doc, I see a text diff of the changes.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment