How do I export the revision history of a gdoc to git?

后端 未结 2 1038
醉酒成梦
醉酒成梦 2021-01-31 04:59

I have a spreadsheet in google docs that I\'d want to integrate in a git workflow (and push to github). Are there any tools (or even libraries that are gdoc version aware) that

2条回答
  •  [愿得一人]
    2021-01-31 05:29

    I was intrigued by your question, so I hacked together a little project today:

    • https://github.com/larsks/gitdriver

    Given a document id, it will create a git repository using either the plain text or HTML content of a Google Docs document. This could easily be extended to work with other file types. It looks something like this when it works:

    $ python gitdriver.py -T 1j6Ygv0ow5A8_ywTMwJbuKVrxrSsSH2wJs3a8Q66mvt4
    Create repository "Untitled"
    Initialized empty Git repository in /home/lars/projects/gitdriver/Untitled/.git/
    [master (root-commit) 24d35e7] revision from 2013-01-08T21:57:38.837Z
     1 file changed, 1 insertion(+)
     create mode 100644 content
    [master fd243ee] revision from 2013-01-08T21:57:45.800Z
     1 file changed, 1 insertion(+), 1 deletion(-)
     rewrite content (95%)
    [master 5ad1a26] revision from 2013-01-09T01:47:29.593Z
     1 file changed, 1 insertion(+), 1 deletion(-)
     rewrite content (92%)
    $ cd Untitled
    $ git log --oneline
    5ad1a26 revision from 2013-01-09T01:47:29.593Z
    fd243ee revision from 2013-01-08T21:57:45.800Z
    24d35e7 revision from 2013-01-08T21:57:38.837Z
    

    This requires you to set up the necessary application credentials with Google. And it doesn't do any error checking. And may eat your goldfish. This is meant as a demonstration of the API and how you might do something like this; it's not intended to be a functional product.

提交回复
热议问题