Undo/revert reverts files to incorrect (old) state, deleting committed code
Description
When using the "revert messages" / undo functionality in the OpenCode TUI, files in the working directory were reverted to an old state (from weeks ago), not to the state before the reverted message. This caused ~1300 lines of committed code to be silently deleted from the working directory.
Steps to Reproduce
- Have a project with recent commits (e.g., commits from the past 2 weeks)
- Use "revert messages" or undo in the OpenCode TUI to undo a recent message
- Run
git status — shows many modified files
- Run
git diff --stat — shows massive deletions
Expected Behavior
Files should be reverted to their state before the undone message's changes, preserving all other committed code.
Actual Behavior
- Multiple files were modified (uncommitted changes appeared)
git diff --stat showed ~1300 lines deleted across ~35 files
- The deleted code was from commits made days/weeks ago (not from the reverted message)
- Affected files included core entities, DbContext, services, etc.
- Running
dotnet build failed with 40+ errors due to missing properties/entities
git reflog showed NO reset/revert operations — changes were only in working directory
git checkout -- . restored everything correctly
Environment
- OS: Windows 10
- OpenCode version: latest as of Jan 2026
- Shell: PowerShell / Git Bash
Workaround
Run git checkout -- . to restore all files to the last committed state.
Impact
High — This bug can silently delete large amounts of committed code without any warning. Users may not notice until build fails or runtime errors occur. If users commit these changes without reviewing, they could lose significant work.
Related Issues
Undo/revert reverts files to incorrect (old) state, deleting committed code
Description
When using the "revert messages" / undo functionality in the OpenCode TUI, files in the working directory were reverted to an old state (from weeks ago), not to the state before the reverted message. This caused ~1300 lines of committed code to be silently deleted from the working directory.
Steps to Reproduce
git status— shows many modified filesgit diff --stat— shows massive deletionsExpected Behavior
Files should be reverted to their state before the undone message's changes, preserving all other committed code.
Actual Behavior
git diff --statshowed ~1300 lines deleted across ~35 filesdotnet buildfailed with 40+ errors due to missing properties/entitiesgit reflogshowed NO reset/revert operations — changes were only in working directorygit checkout -- .restored everything correctlyEnvironment
Workaround
Run
git checkout -- .to restore all files to the last committed state.Impact
High — This bug can silently delete large amounts of committed code without any warning. Users may not notice until build fails or runtime errors occur. If users commit these changes without reviewing, they could lose significant work.
Related Issues