LibreOffice 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.


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.

You can read more about it here.


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

Well, text is text. But the issue with git is it uses text files, and Open/LibreOffice is zip file of documents.

If you use it straight, you’ll just see this when you commit:

Binary files "a/overview.ods" and "b/overview.ods" differ

However, using some text processors, we can easily get it to show us what’s being changed. 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
odt2txt --raw "[email protected]" | /usr/bin/xmllint --format -

The program parses the document into text. 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 show up in the commits:


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.