# Using git with Word documents

Published:

I like git, and I like to use it with most of my projects. But I mostly need to use Word to write manuscripts because it what and my co-authors and journals know how to work with.

Word uses a binary format, so git diff normally displays nothing useful. Martin Fenner posted an incredibly useful blog post that solved this whole problem for me.

I’m on OSX. First, I got Pandoc, a tool that turns Word files into simpler text formats that can be more easily piped into diff.

Second, I needed to add some lines to the .gitconfig file in my home directory:

[diff "pandoc"]
textconv=pandoc --to=markdown
prompt=false
[alias]
wdiff=diff --word-diff=color --unified=1


Third, in the git repo, I needed to create a new file .gitattributes with contents:

*.docx diff=pandoc


Et voila! git diff works just like I would hope.