Skip to main content
RapidDev - Software Development Agency
cursor-tutorial

How to undo bad Cursor suggestions

Accepting a bad Cursor suggestion can leave your code in a broken state with partial changes across multiple files. Cursor provides checkpoints, Git integration, and undo functionality to recover quickly. This tutorial shows how to use checkpoints, git reset, and targeted reverts to undo bad suggestions without losing your other work.

What you'll learn

  • How to use Cursor checkpoints to restore previous states
  • How to revert specific files while keeping others
  • How to use git stash and reset for granular undo
  • How to prevent bad merges with pre-acceptance habits
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read10-15 minCursor Free+, Git-based projectsMarch 2026RapidDev Engineering Team
TL;DR

Accepting a bad Cursor suggestion can leave your code in a broken state with partial changes across multiple files. Cursor provides checkpoints, Git integration, and undo functionality to recover quickly. This tutorial shows how to use checkpoints, git reset, and targeted reverts to undo bad suggestions without losing your other work.

Undoing bad Cursor suggestions safely

Cursor's Agent mode can modify multiple files in a single operation. When a suggestion goes wrong, you need to undo it quickly without losing other work. This tutorial covers every recovery method from Cursor's built-in checkpoints to Git-based selective reverts.

Prerequisites

  • Cursor installed with Git initialized
  • A project with recent Cursor-generated changes to undo
  • Basic Git knowledge (commit, reset, stash)
  • Familiarity with Cursor's Composer panel

Step-by-step guide

1

Use Cursor's built-in checkpoint restore

Cursor creates automatic checkpoints before every Agent mode operation. Click the restore icon in the Composer panel to revert all changes from the last operation instantly.

Cursor Composer panel
1// In the Cursor Composer/Agent panel:
2// 1. Look for the checkpoint icon (clock/restore icon)
3// next to the last operation
4// 2. Click it to restore all files to their state
5// BEFORE the last Agent operation
6// 3. This reverts all files that were modified,
7// including ones you did not ask the Agent to touch
8//
9// Checkpoints are created automatically — no setup needed.

Expected result: All files restored to their state before the last Agent operation.

2

Revert specific files with git checkout

If you want to keep some changes but revert others, use git checkout to restore specific files while leaving the rest untouched.

Terminal
1// Terminal: Revert specific files only
2git checkout -- src/services/UserService.ts
3git checkout -- src/routes/users.ts
4
5// Keep changes in these files:
6# src/components/UserProfile.tsx (has good changes)
7# src/hooks/useUser.ts (has good changes)
8
9// Verify what is still modified:
10git status

Pro tip: Use git diff --name-only to see all modified files before deciding which to revert. This gives you a complete picture of what Cursor changed.

Expected result: Specific files reverted while other changes are preserved.

3

Use git stash for temporary safekeeping

If you are unsure which changes to keep, stash everything first. Then selectively restore the good changes from the stash.

Terminal
1// Save all current changes:
2git stash push -m "before reverting cursor changes"
3
4// Your working directory is now clean.
5// Selectively apply good files from the stash:
6git stash show -p | git apply --include='src/components/*'
7
8// Or restore the entire stash if you change your mind:
9git stash pop

Expected result: Changes safely stashed, with selective restoration of the good parts.

4

Revert to a specific Git commit

If you committed before the Cursor session (as recommended), you can reset to that commit. This is the nuclear option that reverts everything since the checkpoint commit.

Terminal
1// Find the pre-Cursor commit:
2git log --oneline -5
3
4// Soft reset preserves changes as unstaged:
5git reset --soft HEAD~1
6
7// Or hard reset discards everything:
8# git reset --hard HEAD~1
9# WARNING: This permanently discards all changes since the commit.
10# Only use if you are certain you want to lose everything.

Expected result: Working directory restored to the state of the selected commit.

5

Prevent bad merges with pre-acceptance habits

Build habits that make undo easier: commit before every Cursor session, use Plan Mode for complex tasks, and review diffs before accepting.

Workflow
1// Pre-Cursor session checklist:
2// 1. Commit current work: git add -A && git commit -m 'checkpoint'
3// 2. Start a new Cursor Chat/Composer session
4// 3. Use Plan Mode (Shift+Tab) for complex tasks
5// 4. Review every diff before clicking Accept
6// 5. Test after accepting (compile + tests)
7// 6. Commit good results immediately
8//
9// This gives you a clean commit to revert to if needed.

Expected result: A safety workflow that makes every Cursor session reversible.

Complete working example

scripts/cursor-safety.sh
1#!/bin/bash
2# Cursor Safety Script run before every AI coding session
3# Creates a checkpoint commit and branch for safe experimentation
4
5set -e
6
7# Get current branch name
8BRANCH=$(git branch --show-current)
9TIMESTAMP=$(date +%Y%m%d-%H%M%S)
10
11# Check for uncommitted changes
12if [ -n "$(git status --porcelain)" ]; then
13 echo "Committing current changes as checkpoint..."
14 git add -A
15 git commit -m "checkpoint: before cursor session $TIMESTAMP"
16fi
17
18# Create a backup branch
19BACKUP="backup/$BRANCH-$TIMESTAMP"
20git branch "$BACKUP"
21echo "Backup branch created: $BACKUP"
22echo ""
23echo "Safety checkpoint complete."
24echo "If Cursor makes bad changes, run:"
25echo " git reset --hard $BACKUP"
26echo ""
27echo "Or restore specific files:"
28echo " git checkout $BACKUP -- path/to/file.ts"

Common mistakes when undoing bad Cursor suggestions

Why it's a problem: Using git reset --hard without checking what will be lost

How to avoid: Use git stash first to save everything, then selectively restore. Or use git reset --soft to unstage without discarding.

Why it's a problem: Not committing before Cursor sessions

How to avoid: Run 'git add -A && git commit -m checkpoint' before every Cursor Agent session. Make it muscle memory.

Why it's a problem: Accepting changes without reviewing the diff

How to avoid: Always review the diff in Cursor's panel before clicking Accept. Check red lines (deletions) first.

Best practices

  • Commit to Git before every Cursor Agent session as a checkpoint
  • Use Cursor's built-in checkpoint restore for the quickest undo
  • Use git checkout for selective file-level reverts
  • Use git stash when unsure which changes to keep
  • Review diffs before accepting to prevent bad merges entirely
  • Create a backup branch before experimental Cursor sessions
  • Run tests immediately after accepting changes to catch issues early

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I accepted a Cursor AI suggestion that modified 8 files but only 3 of the changes are correct. The other 5 files need to be reverted. I have not committed yet. What is the safest git workflow to keep the 3 good files and revert the 5 bad ones? Show commands for each step.

Cursor Prompt

In Cursor Chat (Cmd+L): @git I accepted changes from the last Agent session but the modifications to src/services/ are wrong. The changes to src/components/ are good. How do I revert only the service files while keeping the component changes? Show the git commands.

Frequently asked questions

Does Cursor have built-in undo?

Yes. Cursor creates automatic checkpoints before Agent mode operations. Click the restore icon in the Composer panel to revert the last operation. This is the fastest way to undo.

Can I undo changes from multiple Cursor sessions ago?

Cursor checkpoints only cover the last operation. For older changes, you need Git. This is why committing before every session is essential.

Will undo affect my Git history?

Cursor's checkpoint restore does not create Git commits. It modifies files in your working directory. Git-based reverts (reset, checkout) do affect history depending on the command used.

What if I already committed bad Cursor changes?

Use git revert HEAD to create a new commit that undoes the last one. Or use git reset --soft HEAD~1 to uncommit and then selectively re-stage the good changes.

How do I avoid needing to undo in the first place?

Use Plan Mode (Shift+Tab) to review the plan before execution. Start with small, focused tasks. Review every diff before accepting. Commit after each successful step.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.