DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

What to Do When an AI Agent Changes or Deletes Files

A practical recovery guide for unexpected AI-agent file edits or deletions: assess the scope, use the right checkpoint or Git source, and verify what was restored.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If an AI agent changed or deleted a file unexpectedly, stop it from making further changes, identify exactly what was affected, and inspect the available history before restoring anything. Use the agent’s checkpoint or rewind only if it covers the change; for tracked files, Git may provide another recovery point. If neither contains the file, check your operating system, sync provider, or backup system. No single rollback method necessarily reverses shell commands or actions outside your workspace.

1. Stop the activity and assess what changed

  1. Stop further risky work. If the agent is still running or an unwanted operation is underway, use the session’s stop or cancel control. Avoid starting another task that could overwrite the affected files.
  2. Establish the scope. Identify the earliest unwanted change and list the affected paths. Check the editor’s change list or checkpoint view, then review source-control status and diffs, recent agent tool calls, terminal output, and error messages.
  3. Separate file edits from other effects. Determine whether the impact is limited to workspace files or also includes a shell command, network request, deployment, or change to an external service. The recovery method depends on that distinction.

VS Code’s agent recovery guide recommends establishing the scope before choosing a recovery action. Preserve useful evidence—such as the diff or command output—while you investigate, and don’t restore broadly until you know which work you need to keep.

As an Amazon Associate I earn from qualifying purchases.

2. Check whether the agent session has a suitable recovery point

Agent rollback features are product- and session-specific. A checkpoint or rewind can help only if a suitable recovery point exists and covers the unwanted change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Recovery option What it may restore Limits to account for
VS Code checkpoint Affected workspace files and chat history, when a checkpoint from before the change is available. Checkpoints are temporary. They do not reverse completed terminal commands, network requests, deployments, or changes to external services.
GitHub Copilot CLI rewind The conversation, or the conversation plus files tracked by that CLI session, depending on the option chosen. File restoration requires file-change tracking and a rewind point. The CLI can skip files that no longer match its last written content or are too large to back up.
Git restore A specified tracked path, restored from the index by default or from a chosen tree such as a commit. It replaces the working-tree contents with the selected source. It cannot recover content that never entered a recoverable Git state.

Restore a VS Code checkpoint

In a supported VS Code agent session, inspect the available checkpoints and select one from before the unwanted file changes. Review what the checkpoint will affect before confirming. A checkpoint restore can also rewind chat history; it is not an undo for terminal or outside actions. Microsoft states: “Checkpoints don’t reverse terminal commands, network requests, deployments, or changes to external services.” See Get an agent back on track for the current session controls and details.

#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Rewind a GitHub Copilot CLI session

GitHub documents /undo or /rewind, and pressing Esc twice while idle, to open the CLI’s rewind picker. Choose conversation-only rewind if you want to change the conversation without restoring files, or choose the option that also restores files if the session has a suitable rewind point and file tracking was enabled. File restoration is relative to the state before the selected prompt began; inspect the result because some files may be skipped. Follow the current Copilot CLI rollback instructions for the exact behavior in your version.

Do not assume another IDE or agent has either of these controls, or the same rollback boundaries. Check that product’s documentation and the controls available in the affected session.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

3. Restore a tracked file with Git

First inspect the working tree. GitHub’s Copilot CLI recovery guidance recommends git status to see modified, staged, and untracked paths, and git diff to review unstaged changes. If a file is staged, inspect the staged diff too with git diff --staged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git status
 git diff
 git diff --staged

For a specific tracked path, git restore uses the index as its source by default. For example, to restore a deleted tracked file from the index:

Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
git restore -- path/to/file

To restore that path from a known-good commit instead, specify the source:

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

Replace the example path and commit with the ones you have verified. A path-specific restore limits the target, but overwrites that path’s current working-tree contents with the chosen source. If the path is absent from the selected source, Git removes it to match that source. The Git restore manual also documents --patch for selecting changes interactively. Review the diff and source before restoring, especially if the file contains unrelated edits you want to keep.

Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

4. Look beyond agent history and Git when needed

If the missing content is not present in an agent recovery point or a Git source you can use, check the recovery options actually configured for your system. Depending on your setup, these may include:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Your operating system’s deleted-items or file-recovery feature.
  • Your cloud or network sync provider’s file history or deleted-file recovery.
  • A backup system that captured the file before the change.
  • The affected external service’s own recovery controls, if the agent changed something outside the workspace.

These options vary by system and configuration; they are not guaranteed to exist or to contain the needed version. In particular, Git restore only draws from the index or a chosen tree, so it is not a substitute for a backup of content that never entered Git’s recoverable history.

Best Value
Sale
UnionSine 500GB Ultra Slim Portable External Hard Drive HDD-USB 3.0
  • [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.

5. Verify the result, then reduce the risk next time

Verify recovery

After a restore or rewind, check git status and inspect the relevant diff again. Open the recovered files and confirm that the content is the version you intended. Separately check any commands or external actions identified during triage: a file rewind does not show that those actions were reversed.

Set safer boundaries for future agent work

  • Before a large or risky task, create a known-good Git commit so there is a clear starting point.
  • Define the files or areas the agent may change and state acceptance criteria; for larger tasks, ask it to propose a plan first.
  • Review the first meaningful changes early rather than waiting until the whole task is complete.
  • Keep manual approval for unfamiliar workflows, particularly when tools can run commands or affect external services.
  • Use permission controls and sandbox boundaries suited to the tools involved. VS Code’s trust and safety documentation distinguishes terminal sandboxing from file access: its terminal sandbox applies to terminal commands and child processes, while built-in file tools use VS Code’s permission system. Platform support and maturity vary, and sandboxing is not a universal undo mechanism.

A Git worktree, an agent checkpoint, a terminal sandbox, a remote repository, and a general backup solve different problems. Treat each according to what it actually records or restricts, rather than assuming any one of them protects every file or outside action.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$229.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$208.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.