How to Integrate git in my Scrivener Workflow?

26 Aug 2013

How to combine one of the best authoring tools ( Scrivener ) with one of the best revision control systems ( git )?

It’s really very simple, even for existing projects. Here is the basic pattern:

  1. Using your preferred git tool, add the directory containing your Scrivener project to a new repository
  2. Add, then commit, all existing files to the repo
  3. Work on your project within Scrivener
  4. Whenever you want, commit your changes to the repo

With git, or really any revision control system, you can easily review and roll back changes. Project branches make it easy to try different ideas, keeping only the ones you like, with little risk.

Let me walk through my pattern with an example. For this example suppose the following:

  1. I keep all my Scrivener in a directory named Scrivener Projects
  2. I have an existing project named Basic. Thus in the Scrivener Projects directory there exists Basic.scriv (Unix format):

    ~/Scrivener Projects/Basic.scriv

Here is how I have git manage this project.

  1. Scrivener produces some files we don’t want git to track. These files are not important, and and are automatically generated. We want to tell git to ignore these files. In my ~Scrivener Projects/Basic.scriv directory I create a .gitignore file:

    touch ~/Scrivener\ Projects/Basic.scriv/.gitignore

To this file I add the following:


Note: thanks to Roy Liu for putting the .gitignore file in his scrivener starter project.

  1. I add ~/Scrivener Projects as a new git repo. For the command line git client this is:
  2. cd ~/Scrivener\ Projects
  3. git init
  4. I add Basic.scriv to the repo:
  5. git add Basic.scriv
  6. Commit the new files to the repo:
  7. git commit -m “Added existing document”

That’s it!

comments powered by Disqus