Repository navigation
Closed
Labels
Description
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 --statshowed ~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 buildfailed with 40+ errors due to missing properties/entities git reflogshowed NO reset/revert operations — changes were only in working directorygit 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
- i input /undo just undo conversation,not file #8098 — opposite problem (undo doesn't revert files at all)
- Undo/revert fails for files with non-ASCII filenames on Windows #10210 — undo fails for non-ASCII filenames on Windows
- UI stuck on '2 message reverted' while model runs invisibly #9811 — UI stuck on 'message reverted'
Reacted by Andrea Giacon, Andri Salillari, Piotr Najda , newmanwang, Abhineet Biju and ZHUO Xu
Activity
github-actions commentedon Jan 23, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
AndryHTC commentedon Feb 4, 2026
This is killing me. I have to step out of OpenCode. So many lost changes
Woukim commentedon Feb 4, 2026
And this will be the right decision
f123888 commentedon Feb 6, 2026
It's hard to believe that a project with nearly 100,000 stars would have such a basic bug.
Jebvvnnb commentedon Feb 6, 2026
I've encountered this problem as well, and not just once. I thought I accidentally pressed some button, but it seems this is an ongoing bug... I'm speechless.
AledHe commentedon Feb 13, 2026
Same here via clicking a message and choosing revert. I was trying to revert a interruptted message, and see all my recent git diff also reverted. I realized something happened again felt really frustrated.
Looks like a simple restore/reset --hard if opencode bugged, but we don't know what the bug is, I suggest developers don’t simply do reset/restore (git) with the revert (opencode) for now. This causes disasters.
btw, after seeing the code diff showed up after the revert message, I tried ctrl+x r, no recovery
UPROOT01 commentedon Feb 16, 2026
#7775 (comment)
I think these two might be related because when i hit redo (after I got this other folder reverted to IDK when after an undo), it didnt redo the other foler, i had to restore my last commit which luckily was pretty recent but I completely do not trust the undo/redo commands right now
AndryHTC commentedon Feb 20, 2026
Yes. It's a "you lied once, you are lier forever" situation
github-actions commentedon Apr 22, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
BartekDeveloper commentedon Jul 28, 2026
It still happens.
Cleroth commentedon Jul 28, 2026
Chill guys, they need to wait for GPT 7 to fix this.
... Or just put
"snapshot": falsein your config and use something else because the snapshot system in opencode is just useless.