So, you would like to check for modifications on a Word document that is version controlled with Git, right? Want to see it in a nice and convenient way like you can see on this screenshot? Then read on!
The Simple WayLet's create an empty Git repository and add a simple Word document (I'm using Git from Cygwin here):
rlegendi@WOLFGANG /c/worddiff $ git init Initialized empty Git repository in C:/worddiff/.git/ rlegendi@WOLFGANG /c/worddiff (master) $ git add test.docx rlegendi@WOLFGANG /c/worddiff (master) $ git commit -m "Added draft Word document" [master (root-commit) cbfafeb] Added draft Word document 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.docx
After editing the file, the good thing is that you can see the difference in pure diff format by using the default git diff command:
rlegendi@WOLFGANG /c/worddiff (master) $ git diff diff --git a/test.docx b/test.docx index f50e2d6..c04f096 100644 --- a/test.docx +++ b/test.docx @@ -1,3 +1,4 @@ Some Title Heading And some text... +In his house at R'lyeh, dead Cthulhu waits dreaming.
Now here comes the interesting part!
Configure Visual ToolsIn this example, we are going to link TortoiseSVN's tools to Git. They are nice, working perfectly, nevertheless they are tested and verified in various environments.You don't have to install the client, all these scripts are available online, but if you have already have it installed like me you don't need anything just link it to directly to Git (all the scripts can be found in the TortoiseSVN\Diff-Scripts directory).
In the following example, we will define how to diff word docs by using the diff-doc.js script. Merging them or extending these functionalities to *.pptx, *. odt, *. nb, *.sxw, *. xls or *.dll files is trivial based on this example.
Basically, you don't need anything just open up the .gitconfig file (either the global one in your home or the one in the test git repository's .git folder) and add the following entry to it:
[diff] tool = wdiff [difftool "wdiff"] cmd="wscript.exe \"c:\\Program Files\\TortoiseSVN\\Diff-Scripts\\diff-doc.js\" \"$LOCAL\" \"`pwd`/$REMOTE\""
That two line of configuration is enough. You can try diffing any Word document with your cool new feature by calling specifically the wdiff tool:
rlegendi@WOLFGANG /c/worddiff (master) $ git difftool -t wdiff test.docx
And there you have this nice comparison view! You see a short summary of modifications on the upper left corner, see detailed logs on the left, a nicely decorated diff in the middle, the original file the diff in the middle, the previous version of the document upper right corner, and the current version in the lower right corner.
Hope that helps you guys! Have fun!
A Few Remaining Questions
- Does TortoiseGit have the same functionailty by default?
- Is it possible to hack this together under Linux?