How to recognise when not to gitignore

A tale of carelessness and stupidity

Bobby Jack
Level Up Coding
Published in
4 min readOct 30, 2020

--

Photo by kyler trautner on Unsplash

I’ve been working with version control systems for most of two decades now, so I really should know better. Since starting out with CVS, it’s been drilled in to me:

check in your source, the stuff you can’t recover if you lost it

There’s never an exception to this rule, and if you think there is, think again. I mean it: literally take the time to think about your exception properly, then realise why you should still version control that file.

This is a short tale of careless autocomplete, a quirk of Unix, and a hastily assembled .gitignore file. Reader, beware.

GitHub Pages

I blame GitHub Pages almost as much as I blame myself. It’s not only ridiculously free, it makes the whole process of maintaining a static site stupidly easy. Here, the emphasis is on the stupid.

Not only am I lazy, I’m a bit of a cheapskate too. It’s often a useful combination in a programmer, but in this case it made me value space-saving over sense. Because, you see, GitHub Pages isn’t actually too good to be true: there’s a space limit (1 GB for a site). Obviously, that makes sense, but it led me into thinking I could gitignore something I really shouldn’t.

The Sass file

Sass is a CSS preprocessing language: you write stylesheets in ‘Sass language’, then use Sass to generate corresponding CSS files. I’m still dipping my toe into Sass; for now, I’m just using it to make my main CSS file a little less verbose. The file I work with anyway — that’s the point.

The file that gets generated, the .css file is still the same, of course, and that’s vaguely relevant to my near catastrophe. My overriding mistake was this: I checked in my CSS file, but not my Sass file. That, I chose to .gitignore.

Here’s how my thinking went: it’s a file I never want to serve via my GitHub Pages site, it just generates another file anyway — which is checked in — I can leave it out of version control. Stupid.

The near-disaster

Here’s my typical Sass process:

$ sass css/styles.scss > css/styles.css

--

--

Technologist & writer, Bobby is an Editor at consumer tech site makeuseof.com and ex-Editor-in-Chief of Switch Player Magazine. Read lots more at bobbyjack.me.