Save snapshots of frequently-updated files over time with programmer-strength version control—but without the learning curve. Free software Flashbake captures working files and adds details like the weather and your Twitter status to each version automatically.
What’s Version Control?
Subversion is an open source version control system that keeps snapshots of changing files over time. Git is the new kid on the version control system block. Git’s gotten quite a bit of attention among software developers partly because its creator, Linus Torvalds, also brought you the Linux operating system.
Primarily, software developers use version control systems like Git and Subversion to archive, manage, roll back, and merge code over time. But you can use version control for any kind of file that’s plain text—whether it’s code, creative writing, a to-do list or notes. That’s exactly what science fiction author and blogger Cory Doctorow uses it for, but he didn’t want to manually commit files by hand, like coders do. In response to conversations with Doctorow, programmer Thomas Gideon cooked up Flashbake, a simplified interface to Git that runs in the background and commits versions quietly as Doctorow writes, no intervention required. (Here’s the whole story of Flashbake in Cory’s words.)
As a programmer-turned-writer, Flashbake tickles me pink, because it makes a powerful developer tool available to anyone who’s constantly typing into plain text files. Once you start managing code with Git, you realise pretty quickly that it’s the cat’s pyjamas. But there’s a learning curve and lots of commands to master before you can really get good use out of it. Flashbake gives writers all the benefits of Git in a single command.
What Flashbake Does
In a nutshell, Flashbake does two things quickly and easily:
- Flashbake commits text files you specify to a local Git repository. You can set it to run quietly in the background, while you work, so it can do this without intervention.
- With the right plug-ins enabled, Flashbake automatically embeds ambient information in each version of those files—like the weather, your Twitter status, the last track you listened to—by including it all in each version’s commit message.
What you get is a database of file versions over time, with notes attached that tell you what you were doing, what it was like outside, and what you were listening to at the time. I used Flashbake as I wrote this very article, and pushed my local Git repository to GitHub, a free Git host, to show off Flashbake in action.
Here’s what it looks like:
Check out a history of changes to this post over time for yourself: flashbake_automates_version_control.txt / Commit History. Click on the “Commit” link to see a color-coded file diff between that version and the earlier one, like this:
I configured Flashbake plug-ins to include San Diego’s current weather, my computer’s timezone, my Twitter status, and my recently-played tracks from Last.FM (using the feed). Here’s what one such automatic commit message looked like from an early version of this post late last night:
You know you want to try it yourself. But first, a warning.
Nerd Alert: Who Flashbake Is Really For
Flashbake is a command-line system for advanced users, and requires a Linux-like shell like Cygwin for Windows or Mac OS X’s built-in Terminal. It is most definitely not for folks looking for something like Microsoft Word’s versioning. It is, however, for people who make heavy use of plain text files, don’t mind firing up the terminal and running a script or two, and know what cron is. Since Flashbake is an interface to Git written in Python, you’ll need all three installed to get this party started. Not scared off yet? Cool. Let’s go.
Flashbake’s installation and configuration documentation is already pretty complete, so I won’t duplicate it here. In short, to run Flashbake, you’ll need superuser access and the following installed as usual:
Once you’ve laid that groundwork, download the latest version of Flashbake and extract it. In the extracted directory, run:
sudo python setup.py install
Now you’re ready to start your project. Create a new folder—I called mine write—and cd into it. Then run:
Make the first text file you’re going to track with Flashbake, like my_novel.txt, and type a few lines. Now you’re ready to start tracking its revisions with Flashbake. Create a new file in your project directory called .flashbake (don’t forget the starting dot) and add the name of your text file to it. For example, my Flashbake project tracks two files, called my_novel.txt and this post in a file called flashbake_automates_version_control.txt. So the bottom of my .flashbake configuration file looks like this:
# “Hot files” for flashbake to commit, add yours here my_novel.txt flashbake_automates_version_control.txt
(Flashbake ignores the first line, which starts with the #, because it’s a comment.)
Now we’re almost ready to run Flashbake. First we’ve got to configure a plug-in or two.
Shake and Flashbake Plug-ins
Flashbake plug-ins are the secret sauce that make it a worthy interface to Git. Plug-ins automatically add information to each version’s commit notes, like feed items, the weather, and timezone.
Here’s a full list of the default plug-ins that come with Flashbake. I used four plug-ins in my Flashbake project: weather, timezone, Twitter, and the feed plug-in. As the Flashbake plug-in documentation explains, list the plug-ins you want to use in your .flashbake file and its additional parameters below.
For example, my full .flashbake file looks like this:
# List what plug-ins Flashbake should invoke plugins:flashbake.plugins.weather:Weather,flashbake.plugins.timezone:TimeZone,flashbake.plugins.microblog:Twitter,flashbake.plugins.feed:Feed # Weather plug-in configuration weather_city:San Diego # Feed plug-in configuration feed_url:http://ws.audioscrobbler.com/1.0/user/ginatrapani/recenttracks.rss # limit is optional, defaults to 5 if unused feed_limit:3 # Twitter plug-in configuration twitter_user:ginatrapani twitter_limit:3 # “Hot files” for flashbake to commit, add yours here my_novel.txt flashbake_automates_version_control.txt
Note that the order in which you list the plug-ins matters. I switched weather and timezone’s position to see the weather at the top of each commit message in GitHub’s version list, here.
Now you’re ready to run Flashbake. To try a “dry run” of Flashbake and see what it will commit without actually performing the commit, cd .. to your project directory’s parent and run the following (Where “your_project_directory” is the name of your project directory.):
flashbake -d your_project_directory
You can even add a -v switch in your command to get extra-verbose output for debugging.
You’ll get output similar to this. Tweak your .flashbake file until the output is to your liking.
Once you’ve got Flashbake’s plug-ins working the way you want, simply run the following to save the current state of the file as a version:
To make Flashbake run automatically in the background, use your system’s cron scheduler. Here’s the full list of ways to run Flashbake.
Publish Your Flashbake Git Repository to GitHub
Now you’ve got a local Git repository of file versions. Great, right? Well, not if you can use ’em easily. Git newbs don’t know all the commands to search and diff between versions, but luckily a pretty web hosting solution for Git means you don’t have to know the commands. I published my local Git repository to GitHub to show off my file changes in this post. Register for a free account at GitHub and create a new repository there. Then, push your local repository to GitHub for cloud backup and a good-looking web interface to your project. Use GitHub’s setup instructions to do just that. After I created a repository on GitHub called write, GitHub told me to run the following commands:
Where “existing_git_repo” is your project directory. The git push origin master command is the magical command that pushes your local files to GitHub. By default, you have to do that remote push by hand, but if you’re automating Flashbake’s runs, you can make local commits automatically push to a remote host (like GitHub) using this handy command.
Flashbake is still a very young mechanism for driving Git, and more plug-ins and configuration options are becoming available, so we’ve only scratched the surface here. But adopting programmer version control for writing, lists or notes is something more and more tech-savvy folks will do going forward. Thanks to Leo Laporte and Cory Doctorow for making me aware of Flashbake in this episode of This Week in Tech.
Have you given Flashbake, Git, or GitHub a try? Post links to your projects and let us know how you like it in the comments.
Gina Trapani, Lifehacker’s founding editor, loves using Git for writing as well as coding. Her feature Smarterware appears every Wednesday on Lifehacker.