Skip to content

Git Resource

The git: resource provides structured version control operations for reading repository state and making commits. It replaces ad-hoc shell commands (exec git status, exec git log) with type-safe, composable DAG operations that return structured output.

Where it runs

Both workflow mode and agent mode. In workflow mode it executes as a DAG step. In agent mode, the workflow containing this resource runs as a single callable tool.

Basic Usage

yaml
# resources/status.yaml
actionId: gitStatus
name: Check Repository Status
git:
  operation: status
  workingDir: /path/to/repo
yaml
# resources/commit.yaml
actionId: gitCommit
name: Commit Changes
git:
  operation: commit
  workingDir: /path/to/repo
  message: "feat: add new feature"
  dryRun: true

Operations

OperationDescription
statusShow working tree status (--porcelain -b)
diffShow unstaged changes
logShow commit history
showShow commit details
branchList branches
remoteList remote repositories
addStage files
commitCreate a commit
checkoutSwitch branches or restore files
initInitialize a new repository
cloneClone a repository
pushPush to remote
pullPull from remote

Configuration Options

OptionOperationDescription
operationallThe git operation to perform (required)
workingDirallWorking directory for git commands
pathsadd, checkout, diff, logFile paths to operate on
messagecommitCommit message
branchcheckout, branch, push, pullBranch name
urlcloneRemote repository URL
remotepush, pullRemote name (default: origin)
argsshow, checkoutAdditional git arguments
maxCountlogMaximum commits to show (default: 10)
dryRunadd, commit, checkout, init, clone, push, pullPreview without modifying
formatlog, showCustom git format string

Operation Details

Status

Returns structured output with branch, staged, unstaged, untracked, and conflicted files:

yaml
# resources/status.yaml
git:
  operation: status
  workingDir: /path/to/repo

Output:

json
{
  "success": true,
  "branch": "main",
  "staged": ["file1.go"],
  "unstaged": ["file2.go"],
  "untracked": ["new.txt"],
  "conflicts": []
}

Log

Returns structured commit history:

yaml
# resources/log.yaml
git:
  operation: log
  workingDir: /path/to/repo
  maxCount: 5
  paths: ["src/"]

Output:

json
{
  "success": true,
  "commits": [
    {"hash": "abc123", "author": "Alice", "email": "alice@example.com", "date": "2026-06-13", "message": "fix: bug"}
  ],
  "count": 1
}

Diff

Returns the unified diff with addition/deletion counts:

yaml
# resources/diff.yaml
git:
  operation: diff
  workingDir: /path/to/repo

Commit

Creates a commit with the given message:

yaml
# resources/commit.yaml
git:
  operation: commit
  workingDir: /path/to/repo
  message: "feat: implement search"

Add

Stages files for commit:

yaml
# resources/add.yaml
git:
  operation: add
  workingDir: /path/to/repo
  paths: ["src/main.go", "src/utils.go"]

Dry Run Mode

Every write operation supports dryRun: true to preview what would happen without modifying the repository:

yaml
# resources/dry-run-commit.yaml
git:
  operation: commit
  message: "feat: dangerous change"
  dryRun: true

Best Practices

  1. Always set workingDir - avoid ambiguity about which repository is being operated on
  2. Use dryRun on write operations - verify before committing, pushing, or checking out
  3. Check success field in downstream resources to detect git failures
  4. Use status before add to understand what will be staged
  5. Set maxCount on log to avoid unbounded output

See Also

Released under the Apache 2.0 License.