Git diff and merge on Word docs, using Word's native support.
A tool that allows you to diff and merge Word (.docx) files with git. Currently Mac only.
~/.gitconfig
:[difftool "Word"]
cmd = <PATH TO WORDGIT>/diff.js \"$LOCAL\" \"$REMOTE\"
[mergetool "Word"]
cmd = <PATH TO WORDGIT>/merge.js \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
git difftool -T Word
with any arguments that you
would normally pass to git diff
.git merge
, then, if there are conflicts,
git mergetool -T Word <path to docx file with conflicts>
.No, this is implemented using Apple's scripting support. However, you may be able to use TortoiseGit's Windows implementation of the same feature.
This whole thing is a careful dance around a bunch of Word bugs, but it seems to work pretty well.
git difftool
runs diff.js
as a shebang script, evaluated by osascript
(AppleScript). diff.js
copies the diffed files to /tmp/word_git (we copy them
because Git gives us paths that Word's sandboxing workaround doesn't seem to
like). Then we open and close doc2 (Word's sandboxing workaround doesn't seem
to trigger when you open a document for diffing, but opening and closing it
first sloves that). Finally, we open doc1, run the diff, and close doc1.
Similar to diff. There's some closing and reopening because for some reason Word doesn't merge properly if we don't.