Git in the sandbox
When the workspace is a git repository (a .git directory), the agent's container has no .git. It sees an empty, read-only directory there, and git is a shim: inside /workspace, the command goes to the proxy's git endpoint, which runs the real git on the real repository and returns the output redacted. Outside /workspace, the container's own git runs.
The proxy's git sees the real files; the agent sees only git's output, redacted on the way. A repository's history can hold values committed long ago, which the agent gets only after redaction. Values detection misses come through, as everywhere else.
What works#
| Kind | Commands |
|---|---|
| Reading | status, diff, log, show, blame, ls-files, merge-base, rev-parse, rev-list, describe, show-ref, symbolic-ref, remote -v, remote get-url, config --get, config --list, version |
Writing .git only | add, commit, branch, tag, switch -c, checkout -b, reset (soft and mixed), restore --staged |
Commits land in your repository on the host, with your host's effective git identity for that repository. Push them from the host.
A refused command exits with 128 and says why; the proxy logs it as git refused with the subcommand's name.
What is refused, and why#
- Working-tree changes through git. Switching to another revision,
checkout -- file,restoreof files,stash,merge,rebase,cherry-pick,revert,reset --hard,rm,mv,clean: git would write unredacted content where the agent reads it. - Remotes.
push,fetch,pullandcloneinto the workspace. - Searching file content and commit messages by pattern.
git grep,log -S,log -G,log --grep,-L: a search tells what a hidden value is. Filtering by--authoris allowed and can confirm a guessed author name or email. - Repository and configuration overrides.
--git-dir,--work-tree, every option that names a file or a program, and-c, except the hardening settings Claude Code adds to each call, which are accepted and dropped. No setting of the agent's reaches git. - Anything interactive. No editor, no
add -p, norebase -i, no stdin. - Padding and truncating formats (
%<,%>) and revisions looked up by message text (:/text). - Output over 16 MiB, and binary output.
Known limits#
- Tools that read
.gitthemselves find no repository: anything built on libgit2, go-git or JGit, cargo's git dependencies, IDE integrations, build scripts that read.git/HEAD. Only programs that call thegitcommand work. - Hooks don't run, and commits are not signed.
- No submodules. While the index holds a submodule entry, every command except unstaging is refused.
- Your global git configuration doesn't apply, only the repository's
.git/config. So Git LFS repositories break (the proxy has no git-lfs), and files only your global ignore file ignores (.DS_Store) show as untracked. - Linked worktrees (a
.gitthat is a file) get no git in the sandbox. - The git in the proxy image (Alpine 3.22) can be older than yours; a repository that uses a newer format extension is refused.
- Only the workspace's own
.gitis hidden, not those of repositories nested in it. - Tracked secret files are read-only for the agent: it sees a copy with markers, git sees the real file.
- Every email in git's output is redacted, authors' included.
Pushes from elsewhere#
Repositories outside /workspace use the container's own git, through the gateway. A push over HTTPS is unpacked in a sandboxed child process and blocked if it holds markers or known values that aren't allowed there. For allowlisted git hosts, git@host: and ssh://git@host/ remotes are rewritten to HTTPS in the agent image so pushes stay inspectable.