On Git
web site there is a detailed instruction for version controling Microsoft Word .doc
files with catdoc
.
http://git-scm.com/book/en/Customizing-Git-Git-Attributes
However, I realized that this doesn't work for .docx
files. It seems that you need either docx2txt
or unoconv
instead of catdoc
(found here). I decided to go with docx2txt
for no reason, but I was stuck at the installation of docx2txt
into Mac OS X.
This sort of illustrates the steps. In my understanding, all you need is docx2txt.pl
at somewhere sensible. I thought /usr/local/bin/
would do. I copied it there. Then, according to the instruction, I tried the following:
$ cd /usr/local/bin/
$ echo '#!/bin/bash
docx2txt.pl "$1" -' > docx2txt
When I try this:
$ docx2txt
I got
Can't read docx file <>!
so, docx2txt
seems to be in the path.
Then I edited .gitattributes
in the repository folder (ASCII, LF) to add the following line:
*.docx diff=wordx
Then, I also edited .git/config file in the repository as follows:
[diff "wordx"]
binary = true
textconv = docx2txt
Because the repository is already in use, I didn't do git init
. I edited a .docx Word file in the repository and then typed git diff
in the Terminal. But result was not successful.
Binary files a/foo/foo.docx and b/foo/foo.docx differ
Could anyone have any suggestions?
/usr/bin/
instead of/usr/local/bin/
. This solved the problem in installation, but I couldn't go further. I'll update my question. – Kouichi C. Nakamurasudo make
to install docx2txt. I'm now diffing .dotx files flawlessly on OSX, thanks! (thebinary = true
option is not needed, btw, so the .git/config can be set from the commandline like this:git config diff.wordx.textconv docx2txt
, where docx2txt is given above and placed in $PATH if it isn't and if it can't see docx2txt.pl, the script woun't run and you will fall back to the usual "binary files a/blah b/blah differs") – klang