Every git disaster story starts the same way: "I was about to rebase / reset / clean / let the agent refactor it, and I figured it'd be fine." Sometimes it is. The thirty seconds below are for the other times.
The thirty-second version
Before any command that rewrites history or deletes work, drop a bookmark:
git branch backup/before-rebase
That's it. You now have a second pointer at the exact commit your branch is on. Rewrite, reset, rebase to your heart's content — if it goes wrong, the way back is:
git reset --hard backup/before-rebase
This works because a branch in git is nothing more than a movable sticky note pointing at a commit. Your risky operations move (or rewrite) the note called main or feature-x. The note called backup/before-rebase doesn't move, and as long as something points at a commit, git keeps it forever.
If anyone else ever touches this repo — or your laptop is the only copy — push the bookmark too:
git push origin backup/before-rebase
A backup that exists only locally protects you from git mistakes, not from spilled coffee.
"But doesn't reflog do this for me?"
Roughly, yes — git reflog remembers everywhere HEAD has been, and it's saved many careers. As a backup strategy, though, it has three holes: it lives only in your clone, entries expire (30–90 days by default), and in a panic you're spelunking through dozens of cryptic entries hoping to recognize the right one.
Reflog is the smoke detector. A named bookmark is the fire exit with a light over it.
When to bother
- Before
git rebase(especially-i) - Before
git reset --hardto anywhere - Before
git clean -fdon a tree with untracked work - Before force-pushing anything
- Before handing the repo to a code-generation agent and telling it to "refactor freely"
- Before merging something big you can't easily review line-by-line
Notice the pattern: any time the downside is "hours of forensic git surgery," the thirty seconds is worth it.
One-click save points
Save Point bookmarks the exact state of any commit as a named branch on GitHub — right before you do the risky thing. If it goes wrong, Time Travel restores the bookmark through a reviewed pull request.
Create a save point →Cleaning up afterwards
Bookmarks are cheap but they pile up. Once the risky change has been running in production long enough that you trust it, delete the backup branch — local and remote — and let the next bookmark take its place. A backup/ or savepoint/ prefix keeps them visually grouped so pruning takes seconds.