Skip to content

Playbooks for g

Story-style workflows—solo, team, and on-call. Jump into the full Use cases page anytime.

commands::workspace

Workspace (git worktree) management.

auto-generated This page is built from //! comments in the Rust source. Edit the source and run npm run docs:extract to update it.

Workspace (git worktree) management.

Overview

A “workspace” is a git worktree plus a small metadata record stored in the workspaces table of ~/.config/g/g.db. Git is the source of truth for which worktrees exist on disk; this module adds UI metadata (friendly name, description, creation timestamp).

The store is keyed by repository ID (an auto-increment integer anchored on the repo’s absolute root path) so metadata from multiple repositories coexists in the same database without colliding. For repos using the container layout (set by init or clone --workspace), the key is the container directory’s repo row — which remains stable after the directory reorganisation.

Folder layout

workspace/
  mod.rs     ← this file: dispatch + clone_with_workspace re-export
  shared.rs  ← WorktreeInfo, ResolvedWorkspace, list_worktrees,
               current_repo_id, load_repo_workspaces, reconcile, …
  init.rs    ← `g workspace init` — reorganise into container layout
  clone.rs   ← `g clone --workspace <url>` — clone into container layout
  list.rs    ← `g workspace list`
  create.rs  ← `g workspace create <name>` (+ untracked-file copier)
  switch.rs  ← `g workspace switch [name]` — open shell in worktree
  delete.rs  ← `g workspace delete <name>`
  status.rs  ← `g workspace status`
  rename.rs  ← `g workspace rename <old> <new>`

Source: src/commands/workspace/mod.rs