# dev.knotless.renameBranch

> Published by [lexicons.knotless.dev](https://lexicon.garden/identity/did:plc:yqsg7znbbhfmj3a2nrpnaerk)

✓ This is the authoritative definition for this NSID.

## Description

Renames a branch of a repository.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.renameBranch)
- [Documentation](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.renameBranch/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.renameBranch/examples)

## Definitions

### `dev.knotless.renameBranch`

**Type**: `procedure`

Makes the new branch where the old one is, points the open pulls into the old one at the new, then deletes the old, as `knotless branch --rename`, MCP's rename_branch, does; never the default branch. As the account logged in to this appview's web pages: directly for the owner, through the repository's gateway for a collaborator, which refuses anyone else.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `name` | `string` | Yes | The branch, without refs/heads/. |
| `repo` | `string` (at-uri) | Yes | The repository's dev.knotless.repo record, as dev.knotless.getRepo takes it. |
| `to` | `string` | Yes | Its new name. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `name` | `string` | Yes | The branch, without refs/heads/. |
| `sha` | `string` | No | The commit it points at, in hex, once made. |

#### Errors

- **NotFound**: No such repository.
- **InvalidRequest**: There is no such branch, it is the default branch, the new name is taken, or the gateway refused it.
- **AuthenticationRequired**: No account is logged in to the pages, or its session has ended.

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Makes the new branch where the old one is, points the open pulls into the old one at the new, then deletes the old, as `knotless branch --rename`, MCP's rename_branch, does; never the default branch. As the account logged in to this appview's web pages: directly for the owner, through the repository's gateway for a collaborator, which refuses anyone else.",
      "errors": [
        {
          "description": "No such repository.",
          "name": "NotFound"
        },
        {
          "description": "There is no such branch, it is the default branch, the new name is taken, or the gateway refused it.",
          "name": "InvalidRequest"
        },
        {
          "description": "No account is logged in to the pages, or its session has ended.",
          "name": "AuthenticationRequired"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "name": {
              "description": "The branch, without refs/heads/.",
              "maxLength": 255,
              "type": "string"
            },
            "repo": {
              "description": "The repository's dev.knotless.repo record, as dev.knotless.getRepo takes it.",
              "format": "at-uri",
              "type": "string"
            },
            "to": {
              "description": "Its new name.",
              "maxLength": 255,
              "type": "string"
            }
          },
          "required": [
            "repo",
            "name",
            "to"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "name": {
              "description": "The branch, without refs/heads/.",
              "type": "string"
            },
            "sha": {
              "description": "The commit it points at, in hex, once made.",
              "type": "string"
            }
          },
          "required": [
            "name"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "description": "Renames a branch of a repository.",
  "id": "dev.knotless.renameBranch",
  "lexicon": 1
}
```
