Efficient time travel using version control

Efficient time travel using version control

So... I needed to perform a rarely-needed task the other day. Also, it happened to be the last time I needed to do it, as we are discontinuing the part of our product where it is relevant. Also, it managed to stop working over time due to some library upgrades, code reorganizations, and whatnot.

Getting this to work properly was starting to take a whole lot more effort than I was willing to invest in it. There were multiple issues with facilities not being available in this kind of program (console app), as opposed to that kind of program (asp.net app), due to implicit requirements that would take a lot of investigation to untangle and fix.

I knew for a fact that the functionality used to work before, so given the circumstances, it was an excellent opportunity to use the time machine I keep at hand on my computer.

A car-shaped time machine being struck by lightning to trigger the time jump.
Not used every day, but useful tool anyway.

Using this time machine, I promptly transported myself to a hot, sunny July afternoon one and half years ago, quickly did the task I needed, and could return to this frigid January day.

The time machine is, of course, our git repository. After I gave up the efforts to get the thingamajig working in the current state, I simply git checkout commit-hashed my commit where I first implemented the functionality two summers ago, and after adding several changes that changed in the outside world (and which caused this whole process), ran the program, saved the output, and the thing was over.

This approach is not always applicable. If I needed to maintain the thing into the future, I'd have to untangle the mess. If I needed to do it more than once, I'd consider doing it properly. If we weren't planning to stop providing the outputs of this particular process in the coming weeks, I'd need to find a way to perform this task on demand, without time traveling.

None of these was true, so I could simply use the past functionality without any adverse effects and move on with my day.

Given that they can conjure useful stuff out of thin air, they can time-travel, and they can do much more without leaving their office (or maybe even bedroom), programmers truly are magicians of our time, aren't they?

An illustration of a female magician conjuring up fireballs.
Do not disturb. Programmer at work.