Skip to content
86% off$349 $48.86code BF2026

Guides

Continue Overwrote a Whole File With One Line: Recover It

Continue's agent said "Edit Success" and left one line in your file. Restore it with git, Undo, VS Code Timeline or Time Machine, and stop it recurring.

GuideUpdated 6 min read

On this page

Your Continue agent reported "Edit Success", and the file you asked it to change is now a single line. The rest of your code is gone.

Why it happens

The report behind this page is an issue on Continue's GitHub tracker. As reported (last seen September 2026), the agent's edit tool treats a bare changed line as the entire new file. Accepting the diff then cuts the file down to that line. People using Windsurf have described something similar: code silently deleted or duplicated.

"Edit Success" only means the write went through. It says nothing about whether the new content is right. We can't tell whether your version of Continue still has this bug, so check the issue thread for the current state. The recovery steps and habits below help with any tool that writes to your files.

Recover the file right now

Stop the agent first so it can't write again. Then work down this list until you have the file back.

1. The last commit has the good version

Keep a copy of the damaged file, then restore from the last commit.

bash
cp path/to/file /tmp/file.damaged
git restore --source=HEAD -- path/to/file

The first line saves the broken version. The second replaces the working copy with the version from your last commit. Plain git restore path/to/file reads from the staging area instead, which matches the last commit only if you haven't staged anything for that file.

If your good work was uncommitted, the last commit won't have it. Use one of the next options.

2. The file is still open in your editor

  1. Click the file's tab.
  2. Press ⌘Z (Command-Z). If the agent's change landed in the open editor buffer, Undo often steps back to the earlier content.
  3. Keep pressing it until the content returns, then save and commit right away.

Closing the tab or restarting the editor clears Undo history.

3. You use VS Code

Open the file, then open the Timeline view in the Explorer sidebar. It lists earlier saves of the file and, in a git repo, its commits. Open an entry, compare it with the current file, and restore what you need. It only knows about saves VS Code itself recorded, so changes made outside the editor may be missing.

4. Time Machine or another backup

If Time Machine backs up the folder, open the folder in Finder, enter Time Machine, and restore the file from a point before the edit. The copy is only as recent as the last backup.

5. You already committed the one-line version

Find the last good version in history and restore from it:

bash
git log --oneline -- path/to/file
git restore --source=<commit> -- path/to/file

The first command lists the commits that touched the file. Replace <commit> with the hash of the last good one. The second command overwrites the working copy of that one file, so copy it aside first if it holds changes you want.

Which recovery method to use

SituationMethodLimit
Last commit has the good versiongit restore --source=HEAD -- path/to/fileLoses uncommitted changes in that file
File still open in the editor⌘ZGone once the tab closes or the editor restarts
VS Code, no usable commitTimeline viewOnly saves VS Code recorded
Folder is backed upTime MachineOnly as recent as the last backup
Bad version already committedgit log, then git restore --source=<commit>Needs a good commit in history

Check what else the agent touched

Don't assume only one file was hit. Look at the whole working tree:

bash
git status
git diff --stat

git status lists changed files. git diff --stat shows lines added and removed per file. A file that lost hundreds of lines and gained one looks exactly like this bug. A file that gained a large block of repeated code looks like the duplication Windsurf users described.

Run git diff path/to/file on each suspicious file and read it. If a file mixes good and bad changes, git restore -p path/to/file asks about each hunk and lets you discard them one at a time.

Stop it happening again

Commit before every agent run

A clean commit is your undo button. Before you start an agent on a task:

bash
git add -A
git commit -m "checkpoint before agent"

git add -A stages everything your .gitignore doesn't exclude, including new files, so glance at git status first if the folder holds anything you don't want in history. If you later want the checkpoint gone but the changes kept, git reset --soft HEAD~1 undoes the commit only.

Give the agent its own branch or worktree

A throwaway branch keeps a bad run away from your main branch:

bash
git switch -c agent/try-edit

A worktree goes further. It is a second checkout of the same repo in another folder, so the agent edits files that aren't your working copy. Use it instead of the branch command above, since both create the same branch name:

bash
git worktree add ../myrepo-agent -b agent/try-edit

A worktree starts from a commit, so commit your work first or it won't be in the new folder. To remove the worktree afterward, run git worktree remove ../myrepo-agent. The branch stays until you delete it.

Read the diff before you accept

Other warning signs:

  • A file shrinks to a handful of lines.
  • The same block appears twice.
  • Imports, headers or closing braces are gone.

To take changes selectively, git add -p stages one hunk at a time and shows you each before it goes in.

Ask for one change at a time

A single clear change leaves a diff you can check in seconds. A request to rewrite half a file produces a diff you'll be tempted to wave through.

Checklist before you run an agent again

  • Your work is committed, or on a branch you can return to.
  • The agent runs on a separate branch or worktree.
  • You will read git diff --stat before accepting anything.
  • The task is one change, not a rewrite.

If recovery doesn't work

  • git says "pathspec did not match". The file is untracked, so git has no earlier version. Try Undo, Timeline or Time Machine.
  • The restored file is older than you expected. Your last commit predates your recent work. Check Timeline or Time Machine for a newer copy and compare before overwriting.
  • You switched branches or reset after the bad edit. Run git reflog to list where HEAD has recently been. It can show a commit you thought was lost, though not uncommitted edits.
  • The editor reloaded the file from disk. Undo history is cleared, so go to git, Timeline or Time Machine.
  • Nothing recovers it. Rebuild it from the agent's chat transcript if it printed the original, and commit as soon as the file is back.

If you want the bug looked at, report it on Continue's GitHub issue tracker. Include this message:

text
Continue agent edit tool replaced an entire file with one line and reported "Edit Success".
Continue version: (your version)
Editor and OS: (VS Code version, macOS version)
Model used: (model name)
Steps: asked the agent to change one line in a file of about N lines; accepted the diff.
Result: the file now contains only the changed line.
Expected: only that line changes.

Common questions

Does this happen with Copilot too?

The reports behind this page name Continue and Windsurf, not Copilot, so we won't claim it. Committing first and reading the diff apply to any agent.

Is Windsurf still the same product?

As of November 2026, Windsurf's changelog says it is now called Devin Desktop. Search for either name when you look for bug reports.

Can git get back changes I never committed?

Not reliably. Git only stores what was committed or staged. For uncommitted work, use editor Undo, VS Code Timeline or a backup.

Is "Edit Success" a sign the edit was correct?

No. It means the write completed. Check the diff yourself.

Every app.
One purchase.