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

# capy checkout: Switch or Create a Secret Branch

> Non-interactive branch switching with capy checkout. Use -b <name> to create a new branch, add --protected to make it invite-only at the crypto layer.

## Synopsis

```bash theme={null}
capy checkout <branch>
capy checkout -b <new-branch>
capy checkout --protected -b <new-branch>
```

## Description

Switches to the named branch. If the branch doesn't exist and you pass `-b`, Capy creates it first. The `.env` file is rewritten in place with the snippets from the new branch.

## Flags

| Flag           | Description                                                    |
| -------------- | -------------------------------------------------------------- |
| `-b, --create` | Create the branch if it doesn't exist.                         |
| `--protected`  | Mark the new branch as invite-only. Only meaningful with `-b`. |

## Examples

```bash theme={null}
# Switch to an existing branch
capy checkout staging

# Create a new branch from the current state
capy checkout -b hotfix-payments

# Create a protected (invite-only) branch
capy checkout --protected -b production
```

## See also

* [`capy branch`](/cli/branch)
* [Protected branches](/using/branches/protected)
