Skip to content

Instantly share code, notes, and snippets.

@klang
Created April 22, 2014 09:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klang/11172484 to your computer and use it in GitHub Desktop.
Save klang/11172484 to your computer and use it in GitHub Desktop.

Git attributes for .docx diffing

docx2txt

Download and install the docx2txt converter from http://docx2txt.sourceforge.net/

wget -O doc2txt.tar.gz http://docx2txt.cvs.sourceforge.net/viewvc/docx2txt/?view=tar
tar zxf docx2txt.tar.gz
cd docx2txt/docx2txt/
sudo make

(simply follow the INSTALL instructions for your platform)

Then make a small wrapper script to make docx2txt output to STDOUT

echo '#!/bin/bash
docx2txt.pl "$1" -' > /usr/local/bin/docx2txt
chmod +x /usr/local/bin/docx2txt

tell git about docx2txt

echo "*.docx diff=wordx" >> .gitattributes
git config diff.wordx.textconv docx2txt

Use .git/info/attributes if the setting should not be committed with the project.

Git attributes for (Word) .doc diffing

echo "*.docx diff=word" >> .gitattributes
git config diff.word.textconv strings
@kouichi-c-nakamura
Copy link

Also, for "Git attributes for (Word) .doc diffing", the first line
echo "*.docx diff=word" >> .gitattributes
should be instead:
echo "*.doc diff=word" >> .gitattributes

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