You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My project structure has not been easy to use since using opencode undo:
Project structure External-all main project directory (no git or main git), internal three or two multi-end codes are managed by git respectively. In this case, no undo in the system can be used for any code management
It is recommended to refactor undo. Compared with other codex and claudecode, git snapshot cannot satisfy code tracking when there are multiple sub-repositories and there is no git repository at the root of the project, resulting in the inability to roll back code files in a large number of scenarios, and then information is lost, which is a major flaw.
Plugins
/undo
OpenCode version
1.16.2
Steps to reproduce
No response
Screenshot and/or share link
Let me deeply analyze OpenCode’s file operations and undo mechanism in a multi-sub-repository scenario.
The analysis results are very clear. Here are the full conclusions:
OpenCode Undo tracking problem in multi-sub-repository scenario
Root cause
OpenCode uses a separate hidden Git repository (~/.local/share/opencode/snapshot/{projectId}/) to track file changes instead of using the project's own Git. Before each tool call, create a snapshot with git add . && git write-tree.
**Git itself does not index the contents of sub-Git repositories (including submodules). ** Git treats the submodule directory as a pointer to a specific commit (a blob) and does not track file changes within it.
Taking the gaokao-server submodule as an example, 6 files are currently modified (Dockerfile, application-dev.yml, etc.). If I edit files within these submodules during this session:
The Edit tool itself works properly — files can be modified correctly
But /undo cannot roll back these changes — because the snapshot system cannot track changes within submodules
You need to manually restore files within the submodule via git checkout
Comparison at the tool level
Tools
Submodule Change Detection
Submodule Undo
OpenCode snapshot
Untraceable
Cannot Undo
code-review-graph detect_changes
Need to specify submodule repo_root
Not applicable
Native git
Need to enter submodule operation
git checkout can be restored
Possible mitigation options
After editing the submodule file, immediately do git commit in the submodule - so that even if undo fails, it can be restored through git revert
Create a separate OpenCode project for each submodule — track separately, but lose the unified context across repositories
Use JetBrains IDE’s Local History — it does not rely on git and can track file changes in any directory
For your multi-sub-repository project, the safest way is: after editing the files in the sub-module, directly git add && git commit** in the sub-module instead of relying on OpenCode's /undo. This ensures that the code can be restored through git's native capabilities at any time.
Description
My project structure has not been easy to use since using opencode undo:
Project structure External-all main project directory (no git or main git), internal three or two multi-end codes are managed by git respectively. In this case, no undo in the system can be used for any code management
It is recommended to refactor undo. Compared with other codex and claudecode, git snapshot cannot satisfy code tracking when there are multiple sub-repositories and there is no git repository at the root of the project, resulting in the inability to roll back code files in a large number of scenarios, and then information is lost, which is a major flaw.
Plugins
/undo
OpenCode version
1.16.2
Steps to reproduce
No response
Screenshot and/or share link
Let me deeply analyze OpenCode’s file operations and undo mechanism in a multi-sub-repository scenario.
The analysis results are very clear. Here are the full conclusions:
OpenCode Undo tracking problem in multi-sub-repository scenario
Root cause
OpenCode uses a separate hidden Git repository (
~/.local/share/opencode/snapshot/{projectId}/) to track file changes instead of using the project's own Git. Before each tool call, create a snapshot withgit add . && git write-tree.**Git itself does not index the contents of sub-Git repositories (including submodules). ** Git treats the submodule directory as a pointer to a specific commit (a blob) and does not track file changes within it.
Specific impact
/undoUndoKnown GitHub Issues Confirmation
/undocommand only rolls back AI conversation message, not the associated file changes #5474: "any work I do, from a higher-level project, on submodule files, is that not only they don't show up in review, but the /undo doesn't undo anything on those files."Practical impact in your project
Taking the
gaokao-serversubmodule as an example, 6 files are currently modified (Dockerfile, application-dev.yml, etc.). If I edit files within these submodules during this session:/undocannot roll back these changes — because the snapshot system cannot track changes within submodulesgit checkoutComparison at the tool level
detect_changesrepo_rootgitgit checkoutcan be restoredPossible mitigation options
git revertSuggestions
For your multi-sub-repository project, the safest way is: after editing the files in the sub-module, directly
git add && git commit** in the sub-module instead of relying on OpenCode's/undo. This ensures that the code can be restored through git's native capabilities at any time.Operating System
macos、debian
Terminal
cli