Overview
The Git API provides access to git operations for OpenCode projects, including retrieving diffs and repository information.Get Git Diff
Retrieve the git diff for the current HEAD of the project.Path Parameters
number
required
The OpenCode instance port number
Response
string
The git diff output from
git diff HEADstring
Absolute path to the project worktree directory
Example
Response
Error Responses
Invalid Port
No Project Worktree
Git Command Failed
Use Cases
Code Review Integration
Retrieve current changes for code review workflows:CI/CD Integration
Get uncommitted changes before running tests:Monitoring Changes
Poll for changes during development:Notes
The diff is generated using
git diff HEAD, which shows all uncommitted changes in the working directory and staging area.This endpoint requires the project to be a git repository. If the project directory is not a git repository, the endpoint will return an error.