Git and saving your work
Go back to the last version that worked
The last hour of changes made things worse and you want it gone.
- What you get
- The app back at a known good point, with the bad attempt kept on a side branch in case.
- Paste it into
- Your AI tool, in your project
The prompt
The recent changes made things worse. I want to get back to the last version that worked. Show me the recent saved versions (commits) with dates and a one-line summary of each, plus any changes that aren't saved yet. Help me pick the last good one. If I'm not sure, check a couple out temporarily so I can look. Before going back, save everything from the bad attempt on a separate branch so nothing is lost. Then return the main work to the good version in a way that doesn't rewrite history that's already been pushed. Confirm the app runs, and tell me how to look at the abandoned work later.
Use it
Open your AI tool (Claude Code, Codex or Cursor) in your project folder and paste it in.
More in Git and saving your work
Stop committing files that shouldn’t be in Git
The .env file, node_modules or build output ended up in the repository.
Stop building straight on the live site
Every change goes to main and straight to production, tested by your users.
Save versions you can find your way back to
One giant commit called “update” holds a week of work.
Get out of a Git mess without losing work
Conflicts, a detached HEAD or a rejected push, and every suggested command looks dangerous.