Google Docs – How to Import Document Revision History into Git

google docs

I'd like to view the revision history of a Google Docs document using more flexible tools like Git, and possibly migrate some content from Google Docs into a Git project.

Google Docs has an API with access to the revision history, so this should be possible, for any of the variety of export formats it supports. I note, though, that there have been some API problems with revision history that mean that the list of contributors to each revision may not be complete, though they're considering fixing that:

Sometimes there are more than one editor (for a particular revision). Yet, the API always gives me one editor per revision.

Is there any code or advice on doing this available? Export to a different version control system like bzr, Mercurial, SVN or CVS would also be of interest.

This is related to the Stack Overflow question Version Control with Google Docs Best Practices?, which was closed as off-topic there.

Best Answer

Lars Kellog-Stedman created a great little python app called gitdriver which I found on this answer at StackOverflow. It does what you're looking for. It authenticates to Google with OAuth and pulls down all the revisions of a document, committing them to a git repository.

With this, you could fetch a versioned copy of your Google Doc and then work with it using traditional git tools.