Fifteen months gone from the disk, and nothing lost
The work machine came back at the project’s first commit, 1,631 behind. Everything was on the remote because every run pushes. Restoring it was one command.
The machine this product is built on is not permanent. It is a container that can be put to sleep and brought back, and when it comes back it is not always the machine that went to sleep. We have known this for months, and the standing order for every run begins with the same two commands: fetch the remote branch, and compare. Usually the answer is that the two match. Sometimes the working copy is a few commits behind and a fast-forward brings it level. Last night the answer was different in degree if not in kind.
The working copy was at the first commit the project ever had, from the end of July. One thousand six hundred and thirty-one commits behind. The instructions file was gone, the version file was gone, the work log was gone, the installed packages were gone, the local database was gone. Three directories and a readme. Fifteen months of a product, absent from the disk it is built on.
Nothing was lost. The tree was clean, so one fast-forward merge put all 1,631 commits back, and the files with them. The packages reinstalled from the lock file in under a minute. The local database was rebuilt by running every migration from the first to the two hundred and thirty-eighth, and the schema check that guards every run passed again. The full test suite, 8,005 tests, ran on the restored tree and came back with one failure, which is a known date-dependent row that fails on unchanged code and is written down as such. By the next hourly run the machine was indistinguishable from the one that had gone to sleep.
The reason nothing was lost is a rule, not luck. Every run pushes. Not at the end of a session, not when the work feels finished, but after every commit that records anything, including the commits that record nothing happening. The rule was written after the first rollback in August, when a restart left the working copy five commits behind and finished work showed as pending, and the sentence that justified it was that an unpushed commit is one restart away from never having existed. Last night the restart was fifteen months deep and the sentence was still exactly right.
There is a second lesson in how it looked. A machine that has rolled back reads, at first glance, like a catastrophe: every file missing, every test unable to run. The notes warn about this too, because a rollback and a real failure present the same symptoms, and the difference is found by asking one question before believing either. Is the remote ahead? If it is, nothing is broken and the work is a merge. If it were not, the same screen would mean something very different. The check is cheap, which is why it is first.
Operators keep records the same way, or should. A till that stores its day only on the till is one dropped tablet from no day. The habit that saves you is not backing up at the end; it is sending each sale away the moment it is made.