My apologies if you speak the Queen’s English since that title probably has a whole different meaning to you than I intended. In fact, I’m talking about Git, the version control system. Last time I talked about how the program came to be and offered you a few tutorials. If you are a dyed-in-the-wool software developer, you probably don’t need to be convinced to use Git. But even if you aren’t, there are a lot of things you can do with Git that don’t fit the usual mold.
Git is really good at tracking changes in documents. If you write plain text files, Markdown, or TeX files, you are in business. However, there is a trick you can use if you use Word, OpenOffice, or many other word processing programs. As a benefit, you’ll even be able to collaborate with others using different programs.
The trick, described in this post and this one, is to configure Git to use a program called Pandoc to convert your input files into Markdown. The Git program can store both, and you can explain to it that differences in the Markdown file correspond to the differences in the document file.
Pandoc is a tool worth knowing about anyway. It converts to and from a dizzying number of formats. If you want to give yourself a headache, you can expand the graphic from their site and try to trace all the lines.
We’ve seen this sort of thing work for collaborative textbooks and even used to track frequently changing documents like French legal codes going back to the time of Napoleon.
Working on a Web Site
You can easily extend the idea of tracking documents to tracking HTML pages for your website. You could just use it as you create and then upload your files like normal. You can also use specialized workflows. Even if you are the sole creator of the site, being able to rewind to what the site looked like last week or last month is often unexpectedly useful.
Managing your Bash Profile or /etc
If you use Linux, you have a lot of files that configure your environment. Things like your
.emacs, and so on are hard to keep the same if you use multiple machines. Sure, you can
rsync them, but if they ever get messed up, it can be hard to go back and figure out what happened. That’s why I wrote a system for managing this problem using Git. Once it is configured, your machines will automatically pick up any changes you push to the remote host (I keep mine on GitLab). The system is flexible enough to allow for custom configuration per machine and even keep random files in sync for you with just a little setup.
There’s a similar package called etckeeper for keeping track of your system-wide configuration in the
/etc directory. You could argue that configuration files are essentially just code, but the intent isn’t coding but keeping version control and synchronization between machines. Also, in the case of etckeeper, there are modifications so Git will store some metadata that is important for that application.
Git as a Database or Bug Tracker
If you are using Git for development, it only makes sense you could use it for tracking bugs, too. In fact, you can use Git as a simple database. Don’t expect to run SQL queries — this just shows a name-value pair system (the proverbial NoSQL database).
Of course, you can store SQLite database (or anything else) in Git. If you do, you can play some tricks like the Pandoc trick for documents to help Git understand your databases better.
Twitter (Yes, Twitter)
Ever wanted a distributed Twitter implementation? Check out Madrox. We aren’t really sure why we want this, but we do.
Have you ever wanted to show a progression of text screens like a slideshow? Maybe not, but if you did, Git can do that, too. It needs a little help from vim, though.
Even if you never need any of these tricks, some of the methods used to coax Git into doing something unusual might spur you to think of something else. An obvious idea would be a difference program for Gerbers or some other printed circuit board file format. Being able to see what changed between a few revisions of a PC board would be really useful. Obviously, being able to track schematics would be useful, too. Spice models ought to be no problem at all.
Have any useful Git hacks? Leave a link in the comments.