Skip to content

Git Workflow

Sia edited this page May 31, 2026 · 2 revisions

Git Workflow

vibe-coder exposes git read access plus commit/push. Destructive operations (reset --hard, force push, branch -D) are intentionally not exposed in the browser — when really needed, ask Claude in the console.

Read API

Endpoint Returns
GET /api/projects/{id}/git/status branch + short porcelain entries
GET /api/projects/{id}/git/diff unified diff (working tree)
GET /api/projects/{id}/git/log last N commits (sha + message)

SSR view: /projects/{id}/git shows status / diff / log in three cards.

Write API

POST /api/projects/{id}/git/commit

curl -X POST http://localhost:17880/api/projects/my-app/git/commit \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "feat: add settings screen",
    "push": true,
    "onlyTracked": false
  }'
{
  "committed": true,
  "pushed": true,
  "branch": "main",
  "sha": "a1b2c3d4...",
  "log": "$ git add -A\n... $ git commit -m '...'\n[main a1b2c3d] feat: add settings screen\n $ git push origin main\nTo github.com:user/repo.git\n..."
}

Body fields:

Field Default Description
message (required) 3–4000 chars
push true after commit, run git push origin <current-branch>
onlyTracked false use git add -u (skip new files)

log is a transcript of every git command run + their output, suitable for showing the user verbatim if the push fails.

Behavior

  1. Resolves current branch via git rev-parse --abbrev-ref HEAD.
  2. git add -A (or -u when onlyTracked=true).
  3. If git status --porcelain is empty → returns committed=false early.
  4. git commit -m <message> with GIT_AUTHOR_NAME / GIT_AUTHOR_EMAIL defaulted to vibe-coder / vibe-coder@localhost (override via env VIBECODER_GIT_AUTHOR_NAME / _EMAIL).
  5. If push=true: git push origin <branch> with GIT_TERMINAL_PROMPT=0 and GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=accept-new -o BatchMode=yes".
  6. Returns the result. A push failure does not roll back the commit — the user can retry by hitting the form again with push=true on a committed=false POST (which won't double-commit).

Authentication for push

git push itself does not handle credentials — it inherits from:

Remote URL Credential source
https://github.com/.../.git ~/.git-credentials populated by /settings/git-integrations (PAT)
git@github.com:.../.git ~/.ssh/id_ed25519 (generated by the same page)

So before push works, the operator must have registered either a PAT or an SSH key for the target host — exactly as for git clone of private repos.

SSR form

The git page (/projects/{id}/git) has a Commit / Push card:

  • Textarea: commit message (required, 3–4000 chars).
  • Checkbox: "Only tracked files" — maps to onlyTracked.
  • Checkbox: "Run git push origin " — maps to push (default checked).
  • Submit button → POST → redirect back to /projects/{id}/git?flash=....

The flash banner contains the same log transcript so the user can copy the exact error after a push rejection.

What's intentionally NOT exposed

  • git push --force / --force-with-lease
  • git reset --hard <sha>
  • git checkout -- <file> (= discard working tree changes)
  • git clean -fd
  • git branch -D <name>
  • git rebase (interactive or otherwise)
  • git stash
  • git tag / git tag -d
  • Anything that rewrites already-pushed history

If you genuinely need any of these, ask Claude in the project console:

"Reset this project to commit a1b2c3d and force-push to origin." — Claude can run shell commands inside the project workspace and explain the consequences before doing it.

The justification is the same as the no-raw-shell policy: a one-click "reset --hard" in a browser would be devastating when accidentally clicked.

Audit trail

Every commit/push attempt records an audit_log entry with action git.commit, plus detail={"push": true|false} and result OK/FAIL. View at /audit?action=git.commit to see the full history of commits/pushes.

Clone this wiki locally