LibreOffice: How to save in Git friendly format?

LibreOffice saves into files that are zip files. Zip files are generally suboptimal to use with Git: A small change in the document can change most of the zip-file, thus making it impossible for Git to reuse parts which results in the Git repository grows with the full size of the zip file instead of just the few changes.

Is there a way in which I can tell LibreOffice to save in a Git friendly format?

E.g. by saving as a zip file with no compression (ala .tar) or simply saving the document as a dir containing the same files as the unpacked zip file would result in.


Is there a way in which I can tell LibreOffice to save in a Git friendly format?

You can save your files as flat XML (fodt) instead of odt:

If a document is saved as .fodt file it keeps the same data the .odt file would contain. Only that this time the data is represented as human-readable text (which makes the work much easier for the version control system) and not compressed. So saving a document as flat XML makes it possible to keep server space requirements and network load low at the relatively low cost of wasting a few kilobytes on the local hard disks.

Source LibreOffice and Version control


Further Reading

  • .odt vs .fodt: which is most space effective for git repositories?
  • Versioning of OpenOffice/LibreOffice documents using git

ReZipDoc is a tool that uses git clean (and optionally smudge) filters for ZIP based files stored in git (ODT is basically a ZIP file).

IT simply re-zips the ODT without compression, and tells git to treat ODTs as text files. Apart from included images, the data within an ODT, and thus the files within the ODT ZIP, are mostly text based. Thus this approach works nicely with git delta compression. LibreOffice its-self has no problem reading uncompressed ODT files, and thus there is no downside to this approach, apart form having to setup ReZipDoc in the local repositories of all collaborators.

In theory, the final size of the git repo should be more or less the same as if using FODT, provided LibreOffices formats the text parts consistently in both cases.