Opencode maliciously storing state in .git index #7754

Open
opened 2026-02-16 18:08:08 -05:00 by yindo · 4 comments
Owner

Originally created by @MatthewCroughan on GitHub (Jan 27, 2026).

Originally assigned to: @rekram1-node on GitHub.

I see that whenever opencode sees it is in a git repo, it will sneak away some files inside of this git repo inside of .git/opencode. How can I turn this functionality off? It's annoying and very rude to put files in there without the user's consent.

Originally created by @MatthewCroughan on GitHub (Jan 27, 2026). Originally assigned to: @rekram1-node on GitHub. I see that whenever opencode sees it is in a git repo, it will sneak away some files inside of this git repo inside of `.git/opencode`. How can I turn this functionality off? It's annoying and very rude to put files in there without the user's consent.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 27, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6361: No trusted workspace functionality leads to arbitrary commands execution on startup
  • #7163: Security Issue - Autoloading Repository Plugins
  • #8577: Snapshot feature needs safeguards for large directories (home directory filled disk)
  • #8694: OpenCode doesnt respect git env vars

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 27, 2026): This issue might be a duplicate of existing issues. Please check: - #6361: No trusted workspace functionality leads to arbitrary commands execution on startup - #7163: Security Issue - Autoloading Repository Plugins - #8577: Snapshot feature needs safeguards for large directories (home directory filled disk) - #8694: OpenCode doesnt respect git env vars Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Jan 27, 2026):

"snapshot": false in your config, it's used so that you can /undo and /redo changes the agent makes during a conversation

@rekram1-node commented on GitHub (Jan 27, 2026): `"snapshot": false` in your config, it's used so that you can /undo and /redo changes the agent makes during a conversation
Author
Owner

@MatthewCroughan commented on GitHub (Jan 27, 2026):

For me, (and I'm not the biggest user of advanced tools, IDEs, etc) it seems really unusual and uncool for a tool to start storing state in another program's data structure like .git by default.

Can you point me to other third party tools/programs that do stuff like this, and without asking the user for consent?

@MatthewCroughan commented on GitHub (Jan 27, 2026): For me, (and I'm not the biggest user of advanced tools, IDEs, etc) it seems really unusual and uncool for a tool to start storing state in another program's data structure like `.git` by default. Can you point me to other third party tools/programs that do stuff like this, and without asking the user for consent?
Author
Owner

@jsageryd commented on GitHub (Feb 3, 2026):

OpenCode storing a hash in .git/opencode interferes with Git itself; Git thinks it's something it can check out. Minimal example below, but I encountered this trying to checkout+create new branch from a remote branch called origin/opencode; after which git checkout opencode instead checks out the hash in .git/opencode.

$ git version
git version 2.52.0
$ git init foo
$ cd foo
$ touch foo
$ git add foo
$ git commit -m 'Initial commit'
[master (root-commit) 375c6fe45d6d2099] Initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ opencode
$ cat .git/opencode; echo
375c6fe45d6d2099ffb0254a21c64110f628c063

In this state, it's possible to check out opencode:

$ git checkout opencode
HEAD is now at 375c6fe45d6d2099 Initial commit
$ git status
## HEAD (no branch)

Removing .git/opencode fixes it:

$ rm .git/opencode
$ git checkout opencode
error: pathspec 'opencode' did not match any file(s) known to git
@jsageryd commented on GitHub (Feb 3, 2026): OpenCode storing a hash in `.git/opencode` interferes with Git itself; Git thinks it's something it can check out. Minimal example below, but I encountered this trying to checkout+create new branch from a remote branch called `origin/opencode`; after which `git checkout opencode` instead checks out the hash in `.git/opencode`. ``` $ git version git version 2.52.0 $ git init foo $ cd foo $ touch foo $ git add foo $ git commit -m 'Initial commit' [master (root-commit) 375c6fe45d6d2099] Initial commit 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo $ opencode $ cat .git/opencode; echo 375c6fe45d6d2099ffb0254a21c64110f628c063 ``` In this state, it's possible to check out `opencode`: ``` $ git checkout opencode HEAD is now at 375c6fe45d6d2099 Initial commit $ git status ## HEAD (no branch) ``` Removing `.git/opencode` fixes it: ``` $ rm .git/opencode $ git checkout opencode error: pathspec 'opencode' did not match any file(s) known to git ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7754