# Git Sandbox

> Git workflow protocol for agents in sandbox/worktree environments. Covers local-only operations, worktree-aware branch management, and non-interactive conflict resolution. Injected only for git-associated workspaces.

- Skill: `googlecloudplatform/git-sandbox` (Agent Skill)
- Install (CLI): `npx get-skill add googlecloudplatform/git-sandbox`
- Raw SKILL.md: https://api.skillmd.com/api/skills/googlecloudplatform/git-sandbox/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: GoogleCloudPlatform (https://skillmd.com/u/googlecloudplatform)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/googlecloudplatform/git-sandbox

---


# Git Workflow Protocol: Sandbox & Worktree Environment

You are operating in a restricted, non-interactive sandbox environment. Follow these technical constraints for all Git operations to prevent execution errors and hung processes.

## 1. Local-Only Worktree Operations (When `SCION_GIT_DEPTH` Is Unset)

- **Scope:** Applies to host-mounted worktree/shared sandboxes (`SCION_GIT_DEPTH` unset). If `SCION_GIT_DEPTH` is set, your workspace is an in-container per-agent clone — follow the project's remote policy and the `git-operations` skill (`## Shallow Clones`) for `git fetch --deepen` / `--unshallow` and remote pushes.
- **Restriction:** Host-mounted worktree sandboxes have no remote credentials and may be air-gapped from `origin`; `git fetch`, `git pull`, or `git push` will fail unless the project grants remote access.
- **Directive:** In local worktree sandboxes, assume the local `main` branch is the source of truth.
- **Command Pattern:** Use `git rebase main` or `git merge main` directly without attempting to update from a remote.

## 2. Worktree-Aware Branch Management

- **Restriction:** You are working in a Git worktree. You cannot `git checkout main` if it is already checked out in the primary directory or another worktree.
- **Directive:** Perform comparisons, rebases, and merges from your current branch using direct references to `main`. Do not attempt to switch branches to inspect code.
- **Reference Patterns:**
  - **Comparison:** `git diff main...HEAD` (to see changes in your branch).
  - **File Inspection:** `git show main:path/to/file.ext` (to view content on main without switching).
  - **Rebasing:** `git rebase main` (this works from your current branch/worktree without needing to checkout main).

## 3. Non-Interactive Conflict Resolution (Bypass Vi/Vim)

- **Restriction:** You cannot interact with terminal-based editors (Vi, Vim, Nano). Any command that triggers an editor will cause the process to hang.
- **Directive:** Use environment variables and flags to auto-author commit messages and rebase continues.
- **Mandatory Syntax:**
  - **Continue Rebase:** `GIT_EDITOR=true git rebase --continue`
  - **Standard Merge:** `git merge main --no-edit`
  - **Manual Commit:** `git commit -m "Your message" --no-edit`
  - **Any Other Command:** Set the editor via environment variable per command: `GIT_EDITOR=true git <subcommand>`. Do **not** rely on `git -c core.editor=true <subcommand>` — agent harnesses often export `GIT_EDITOR=false` in command subshells, and Git evaluates `GIT_EDITOR` ahead of `-c core.editor`.
  - **Never** run `git config core.editor ...` or otherwise write `core.editor`, `core.hooksPath` or any other key outside the repository git config allow-list (`pkg/util/git_config_policy.go`) into the repository config: brokers refuse to start or resume an agent whose checkout sets one. Pass non-editor config flags per command (`git -c <key>=<val> <subcommand>`), and override the editor with `GIT_EDITOR=true`.

## 4. Conflict Resolution Loop

If a rebase or merge results in conflicts:

1. Identify conflicted files via `git status`.
2. Resolve conflicts in the source files.
3. Stage changes: `git add <resolved-files>`.
4. Finalize: `GIT_EDITOR=true git rebase --continue`.

