Interesting blog post on "academic writing with latex and git"

I came across an interesting blog post titled “A match made in heaven: academic writing with latex and git” by the Oxford Protein Informatics Group.

The author presented an interesting discussion on the use of LaTeX and git.

The main advantage of using git is that it provides version control over your document. Every change you make is tracked, logged and annotated with a description of why it was made. When I open up the document, I can see every change I’ve made and easily go back if I decide I like the way something was before a change. It gives me confidence to edit aggresively because I know I can always go back to what it was before if needed. …

In particular, I was wondering if anyone else was using LaTeX + git (as part of your Scrivener+LaTeX project) for version control of their LaTeX documents.

My understanding of git is practically nil and I’m wondering if I should invest the time and effort to understand how the author of the above blog uses git for LaTeX version control.

After 4 years of writing in Scrivener + LaTeX, I’m still relying on what feels like a rather chaotic methodology consisting of a mostly ad hoc manual system for managing versions of my LaTeX documents.

Thanks for reading,
scrive
:thinking:

Hi Scrive,

I use git for all of my coding work, and I probably would use for writing if I wasn’t so committed to Scrivener. git is really amazing for versioning anything that is text-based, and with some beautiful and free GUIs[1] is not too difficult to learn the basics. Advanced git is mind-bending stuff but this only applies when many people are all working together on the same project, something that would rarely apply to writers.

For the actual text, you certainly should use Scrivener’s snapshots if you don’t already, which serves the same purpose as git. You can select all docs in the binder then do a named snapshot and give it a version and descriptive title so you can track your writing over time…

Although Scrivener’s RTF+folders approach cannot work well with git directly, you could still use git with the output of Scrivener’s compilation. This would give you an additional way to checkpoint your writing. This could be as easy as just using a compile folder that you have set up to also be tracked with git. After a compile, you “commit” the changes and voila! However one major advantage of git is being able to jump back and forwards in history which cannot work as Scrivener’s compiler is output only. But especially for things like LaTeX and its often obscure incantations it may help you visualise changes to your LaTeX templates and other changes you make over the years. If you submit a version somewhere you can tag that commit, add a message etc. then know which version got sent where…


[1] I use GitKraken, not really because it is the best GUI, but mostly because of the superficial reason that the mascot has tentacles, and well, Kraken!

3 Likes

Hi nontroppo,

Thanks for the great outline … not sure I understood all that you mentioned, but it was enough to get me to watch my first Git Tutorial For Dummies.

There’s a nice summary of the basic git commands at the end of the video (see below).

Seems I’ve been working in the Stone Age of version control (how embarrassing!) … Thanks for bringing me into the 21st century!

I particularly like the idea that git is already on my Mac, but that I can connect to GitHub if and when I need to connect to the world. (The best part is my local git is free!)

I’m looking forward to researching all the suggestions you made regarding git!

Thanks again,
scrive
:thinking:

Note that Scrivener projects are not “text-based,” in that Scrivener’s native format is .rtf, not .txt. A number of people have attempted to use Git to manage Scrivener projects over the years, with generally poor results. I would definitely make sure that you have secure backups stored with some other tool.

1 Like

Hi kewms,

Thanks for there heads-up!

Do you know if the .rtf vs. .txt ‘poor results’ issue exists with both the local git on a Mac and the online git (GitHub) versions?

Thanks again,
scrive
:thinking:

The issue is that Git is designed to track changes in plain text, which Scrivener documents are not. That’s a fundamental incompatibility, regardless of where the Git software is located.

1 Like

As @kewms mentions, RTF is not ideally suited to being tracked by git. Technically, RTF is in fact a “text” format, but it mixes RTF commands tightly into the actual text, and RTF commands are not reader friendly. Furthermore, Scrivener uses custom RTF, and this can change over releases so although technically git can manage RTF files, realistically this could cause problems if you want to pull out RTF from one project and put it into a later one. Basically for 97.84% of people git is not advised for directly managing a Scrivener project.

However, my suggestion is to try to use git with your compile folder. This means you don’t worry about RTF, and can track the LaTeX commands as well as the writing. LaTeX is more legible than RTF, as LaTeX commands are more relevant to final layout than RTF commands etc.

1 Like