Git and saving your work
Get out of a Git mess without losing work
Conflicts, a detached HEAD or a rejected push, and every suggested command looks dangerous.
- What you get
- A plain explanation of the state you’re in and a safe route out, with a backup taken first.
- Paste it into
- Your AI tool, in your project
The prompt
My git repository is in a state I don't understand. Help me get out without losing any work. Before changing anything, look at the current state and explain it in plain words: which branch I'm on, what's saved and what isn't, how my copy differs from the remote, and whether a merge or rebase is half finished. Then make a safety copy of everything, including unsaved changes, on a backup branch. Propose the safest way back to a normal state and explain each command before you run it. Don't run anything that discards work (reset --hard, clean, a force push, checkout over files) without showing me exactly what would be lost and getting my OK.
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
Go back to the last version that worked
The last hour of changes made things worse and you want it gone.
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.