The 11 PM Disaster Every Student Knows

Your code worked at 10 PM. Then you decided to improve it — a cleaner loop, a better name, one small refactor before bed. Now nothing works, the error makes no sense, and the version that worked an hour ago exists only in your memory. You press undo twenty times, overshoot, and lose the fix you actually wanted to keep. This is not a rare accident. It is the normal way students lose evenings, and it is almost entirely preventable.

The mistake is not the bad edit. Bad edits are how you learn. The mistake is having no way back. Professional developers almost never lose working code this way, not because they make fewer mistakes, but because they never change working code without a save point first. That is a habit, not a talent — and it takes about a week to make it automatic.

The Habit: Save a Version Before Every Risky Change

The rule is one sentence: if it works, save it before you change it. A working version, a saved version, then the risky change. Run the tests. If the change works, save again — that becomes the new known-good version. If it does not, restore the saved version and try a different approach. You never rewrite from memory, and you never have to choose between your broken new code and your forgotten old code.

What counts as risky? Anything you cannot undo in your head. A refactor that touches five places. A new feature on top of working code. Fixing one bug while changing the function it lives in. And the most dangerous kind: "just cleaning up" before a deadline, when you are tired and the cleanup touches everything. If you are not sure whether a change is risky, save first. The save costs a second; the rewrite costs an evening.

Name your versions the way you would want to find them later. "Working: averages correct" is a version you can trust at midnight. "Final version 2" is not.

Your Editor Already Keeps Versions for You

You do not need to set anything up to start. CoderFile saves a version automatically when you edit a snippet, so the habit is already half built for you. Open Version History on any snippet and you see the list of saved versions, newest first. Pick one and you can view the diff — the lines that changed between that version and your current code — before you decide anything. If the old version is the right one, restore it in one click and you are back to known-good code.

That makes the habit concrete: save the snippet when it works, make the risky change, and check Version History if the change goes wrong. The diff is the part students underuse. Before restoring, read what actually changed. Half the time the diff shows you the one line that broke everything, and you fix that line instead of throwing the whole change away — which is exactly the skill the debugging routine trains: shrink the problem until you can see it.

Try It: Versions in Ten Lines

Here is the whole habit in miniature: a list of grades, a saved version, a bad edit, and a restore. Paste it into the browser editor and run it.

# versions.py — save a version before every risky change
history = [] def save_version(state, note): history.append((note, list(state))) def restore(index): return list(history[index][1]) grades = [82, 91, 77]
save_version(grades, "working version: averages correct") # the risky change: add a grade, and "fix" one that was fine
grades.append(105) # a score above 100 — impossible
grades[0] = 28 # a typo: 82 became 28
print("After the bad edit:", grades, "average:", sum(grades) / len(grades)) grades = restore(0)
print("Restored version 0:", grades, "average:", sum(grades) / len(grades))
print("Saved versions:", [note for note, _ in history])

The bad edit prints After the bad edit: [28, 91, 77, 105] average: 75.25 — two small mistakes, and the average is wrong in a way that looks plausible enough to submit. The restore prints Restored version 0: [82, 91, 77] average: 83.33333333333333: the exact list you saved, back in one call, with no retyping and no guessing. That is the whole habit. The list is your code; the saved version is your way back; the restore is the one click in Version History.

Notice what the example does not do: it never asks you to be careful enough to avoid mistakes. Carefulness fails at 11 PM. A saved version does not depend on your attention.

When a Version Is Not Enough, Graduate to Git

Version history covers one snippet in one editor. Sooner or later you need more: a message that says why you changed something, a branch where you can try an idea without touching the working version, and a copy that lives somewhere other than your laptop. That is Git, and it is the same habit with a bigger toolbox. A commit is a saved version with a message. A branch is a saved version you can experiment on. A push sends your versions to GitHub, where a teacher, a teammate, or a recruiter can see them.

The transfer is direct: if you already save before risky changes, you already think in commits — you only need the commands. Start with the beginner Git guide for init, commit, push, pull, and branching, and practise the workflow in the Dev Workflow Basics course in CoderFile Lab, which covers Git alongside testing and deployment. CoderFile's GitHub integration — connecting a repository so you can push and pull from the editor — is a Pro feature, so learn the habit on Free and connect GitHub when your projects start living there. That is also when a GitHub profile starts to matter, which is why this pairs with your GitHub portfolio: versions you push are the proof behind the projects you pin.

When the Habit Fills Your Free Plan

Stay on Free ($0: 20 executions a day, 10 AI requests a day, 10 saved snippets, 3 private snippets, 3 collaborators per snippet) while it fits — it is enough to build the habit on real coursework. But a good version habit grows a library by design: every working version you keep is a saved snippet, and ten saved snippets fill up fast once you are saving before every risky change. That is the upgrade moment, not a sales pitch: when you have to delete a good version to save a new one, Pro earns its $9/month or $69/year — unlimited saved snippets and executions, 100 AI requests a day, 10 collaborators per snippet, unlimited private snippets, and GitHub integration, which Free does not include. Team ($19/user/month, or $15/user/month billed annually) covers a class saving versions together — see the full comparison on the pricing page.

Your next step starts tonight: open one snippet that works, check its Version History, and make one risky change you have been avoiding — a refactor, a cleaner loop, a better name. If the change works, save the new version with a clear note. If it breaks, restore the old one in one click and try again tomorrow. Then save this article's example as a snippet of its own, so the habit has a save point too. The students who never lose working code are not the careful ones. They are the ones who saved first.