--- title: 'Git' navigation: icon: i-ph:git-branch-duotone description: 'The @devframes/service-git wire service: typed read/write git operations over RPC on one repository, shared by every devframe on the host.' --- Typed read/write git operations shared over RPC by every devframe on the host, generalizing the utilities that used to live inside the [Git devframe](/add-ons/devframes/git). The exec wrapper and output parsers stay internal; consumers get the typed `GitServiceApi` in-process (`ctx.services.get`) and the same ops over `devframes:service:git:*` RPC. Package: `@devframes/service-git` · Scope: `devframes:service:git` ## Installing ```ts defineDevframe({ importMetaUrl: import.meta.url, services: [ { package: '@devframes/service-git', options: { cwd: process.cwd() } }, ], }) ``` A hub installs a shared instance with `initHub({ services: [createGitService(options)] })`. ## Options `GitServiceOptions`: `cwd` merges as a scalar (later installer wins). | Option | Type | Description | |--------|------|-------------| | `cwd` | `string` | Repository directory to operate on. Defaults to the context's `cwd`; the repo root is discovered once (`rev-parse --show-toplevel`) and memoized. | ## RPC functions Registered under `devframes:service:git:*`. Reads are `query`; writes are `action`. Write ops are **always exposed**; authorization is the host's connection-trust boundary. The service defines no `dump`/`snapshot`; a devframe bakes what it needs via `snapshotRpc`. | Function | Type | Args | Returns | |----------|------|------|---------| | `status` | `query` | none | Working-tree status: branch, ahead/behind, staged/unstaged/untracked files. | | `log` | `query` | `{ limit?, skip?, ref?, paths? }` | Commit history, newest first (paginated). | | `show` | `query` | `{ hash, patch? }` | Full detail of one commit: metadata, files, unified patch. | | `readFile` | `query` | `{ path, ref? }` | Contents of a file at a commit-ish (default HEAD). | | `diff` | `query` | `{ path?, staged? }` | Unified diff of uncommitted changes. | | `branches` | `query` | none | Local branches with tracking state and the current branch. | | `tags` | `query` | none | Tags (newest first) with target SHA, date, and subject. | | `stage` | `action` | `{ … }` | Stage paths; returns the new status. | | `unstage` | `action` | `{ … }` | Unstage paths; returns the new status. | | `commit` | `action` | `{ … }` | Create a commit; returns the result. | The read `query` functions carry agent metadata, so they surface as tools to a [coding agent](/guide/agent-native). ## Node API `ctx.services.get('@devframes/service-git')` returns the in-process `GitServiceApi`: the same operations without an RPC hop. ## On the RPC client ```ts const rpc = await connectDevframe() if (rpc.services.has('@devframes/service-git')) { const git = rpc.services.get('@devframes/service-git')! const status = await git.rpc.call('status') console.log(status) } ``` ## Source [`services/git`](https://github.com/devframes/devframe/tree/main/services/git)