# How to undo bad Cursor suggestions

- Tool: Cursor
- Difficulty: Beginner
- Time required: 10-15 min
- Compatibility: Cursor Free+, Git-based projects
- Last updated: March 2026

## 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.

## Before you start

- 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.

```
// In the Cursor Composer/Agent panel:
// 1. Look for the checkpoint icon (clock/restore icon)
//    next to the last operation
// 2. Click it to restore all files to their state
//    BEFORE the last Agent operation
// 3. This reverts all files that were modified,
//    including ones you did not ask the Agent to touch
//
// 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: Revert specific files only
git checkout -- src/services/UserService.ts
git checkout -- src/routes/users.ts

// Keep changes in these files:
# src/components/UserProfile.tsx (has good changes)
# src/hooks/useUser.ts (has good changes)

// Verify what is still modified:
git 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.

```
// Save all current changes:
git stash push -m "before reverting cursor changes"

// Your working directory is now clean.
// Selectively apply good files from the stash:
git stash show -p | git apply --include='src/components/*'

// Or restore the entire stash if you change your mind:
git 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.

```
// Find the pre-Cursor commit:
git log --oneline -5

// Soft reset preserves changes as unstaged:
git reset --soft HEAD~1

// Or hard reset discards everything:
# git reset --hard HEAD~1
# WARNING: This permanently discards all changes since the commit.
# 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.

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

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

## Complete code example

File: `scripts/cursor-safety.sh`

```bash
#!/bin/bash
# Cursor Safety Script — run before every AI coding session
# Creates a checkpoint commit and branch for safe experimentation

set -e

# Get current branch name
BRANCH=$(git branch --show-current)
TIMESTAMP=$(date +%Y%m%d-%H%M%S)

# Check for uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
  echo "Committing current changes as checkpoint..."
  git add -A
  git commit -m "checkpoint: before cursor session $TIMESTAMP"
fi

# Create a backup branch
BACKUP="backup/$BRANCH-$TIMESTAMP"
git branch "$BACKUP"
echo "Backup branch created: $BACKUP"
echo ""
echo "Safety checkpoint complete."
echo "If Cursor makes bad changes, run:"
echo "  git reset --hard $BACKUP"
echo ""
echo "Or restore specific files:"
echo "  git checkout $BACKUP -- path/to/file.ts"
```

## Common mistakes

- **Using git reset --hard without checking what will be lost** — Hard reset permanently discards all uncommitted changes. If you had good changes mixed with bad ones, they are gone. Fix: Use git stash first to save everything, then selectively restore. Or use git reset --soft to unstage without discarding.
- **Not committing before Cursor sessions** — Without a checkpoint commit, there is no clean state to revert to. You must manually identify and undo each bad change. Fix: Run 'git add -A && git commit -m checkpoint' before every Cursor Agent session. Make it muscle memory.
- **Accepting changes without reviewing the diff** — Once accepted, Cursor changes are applied to your files. The checkpoint only restores the last operation, not multiple operations ago. Fix: 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

## 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.

---

Source: https://www.rapidevelopers.com/cursor-tutorial/how-to-revert-partial-code-merges-after-accepting-incomplete-cursor-ai-suggestions
© RapidDev — https://www.rapidevelopers.com/cursor-tutorial/how-to-revert-partial-code-merges-after-accepting-incomplete-cursor-ai-suggestions
