Free Office Version Control

Lately I’ve been looking at different ways to do version control with office documents. I’ve been interested in this because I write stories and It’s nice to be able to see my work as I go along.

I’ve found two different way to do this.

Internal

The first method is using OpenOffice/LibreOffice’s own internal version control system. It’s pretty simple. You just enable the recording of changes under Edit > Changes > Record Changes.

You can adjust how it saves the changes, and how it displays them.

Once you’ve done some changes to a document, you’ll want to use the Accept or Reject Changes window to pick the changes you want to keep (probably all) and to makeĀ  a checkpoint.

I’m still trying it out, but it looks promising.

Git

Woah! Git? I thought this was document editing, not… code.

Well, text is text. But the issue with git is it’s use to text files, and Open/LibreOffice is zip files of docuements.

But no worries. First, install odt2txt and xmllint. Then put this program in your path:

#!/usr/bin/env sh
# place this file to ~/bin/odf2prettytxt and have ~/bin in $PATH
set -o errexit
/usr/bin/odt2txt --raw "$@" | /usr/bin/xmllint --format -

It will parse the document so we can use it. We just need to tell git to use this new program for office docs:

git config --global diff.odf.textconv "odf2prettytxt"

And in our .gitattributes we add this so it knows what types of files it has:

.ods diff=odf
.odt diff=odf
.odp diff=odf

And finally add this to .gitignore so it won’t bother us:

.~lock.*

That’s it. Now we can record the changes as we write the story, making it much easier to go back and get back that really cool passage.

See my notes for more info.