> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gravixlayer.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Git Delete Branch

> Delete a local branch (git branch -d or -D)

```python theme={null}
from gravixlayer import GravixLayer

client = GravixLayer()
runtime = client.runtime.create(template="python-3.14-base-small")

runtime.git.clone(
    url="https://github.com/octocat/Hello-World.git",
    path="/home/user/repo",
)
runtime.git.create_branch("/home/user/repo", "tmp-branch")
runtime.git.checkout("/home/user/repo", "master")

r = runtime.git.delete_branch("/home/user/repo", "tmp-branch")
print(r.success, r.exit_code)

# Force delete: runtime.git.delete_branch("/home/user/repo", "name", force=True)

runtime.kill()
```

The branch must not be the currently checked-out branch when you delete it.

## Parameters

| Parameter         | Type    | Required | Description                                                    |
| ----------------- | ------- | -------- | -------------------------------------------------------------- |
| `repository_path` | string  | Yes      | Path to the repository root inside the runtime                 |
| `branch_name`     | string  | Yes      | Branch to delete                                               |
| `force`           | boolean | No       | If true, use force delete (`-D`); otherwise safe delete (`-d`) |

## Response

| Field       | Type    | Description                                    |
| ----------- | ------- | ---------------------------------------------- |
| `success`   | boolean | Whether the git command completed successfully |
| `exit_code` | integer | Process exit code from `git`                   |
| `stdout`    | string  | Standard output from `git`                     |
| `stderr`    | string  | Standard error from `git`                      |
| `error`     | string  | Error message when the operation fails         |
