# hlix repo

**Use `hlix repo` to work with the code of your projects, the way `gh repo` does for a GitHub repository.** A project's code is stored in HLIX Repos, hlix's own code storage, or on GitHub. The commands take a project and work for both.

`<project>` is an ID, a name, or `workspace/name`. A name that two projects share is refused: use the ID.

## Prerequisites

- A credential that reaches the workspace (see [`hlix auth login`](/reference/cli/auth/))
- Git on your path, for `clone`

## `hlix repo list`

```bash
hlix repo list [--json]
```

Lists the projects of the workspace that have code: the project, its workspace, where the code is stored and the default branch. A project that never stored any code is not listed. `--workspace <id>` lists another workspace.

With `--json`, `data` is `{workspace, repos}`; each repo has `projectId`, `project`, `workspaceId`, `workspace`, `source` (`github` or `hlix-repos`), `repository` (`owner/name` for GitHub, otherwise `null`) and `defaultBranch`.

## `hlix repo view`

```bash
hlix repo view [<project>] [--json]
```

Shows where one project's code is stored, its default branch, its latest commit, whether anything is stored yet and the command that clones it. With no project, the project this folder is bound to is shown. A project with no code yet exits 1 with `outcome: no_code`.

## `hlix repo clone`

```bash
hlix repo clone <project> [<directory>] [--into <parent>] [--open] [--json]
```

Clones the project's code into a new folder: `<directory>`, or a folder named after the project in `--into <parent>` or the current folder. A folder that exists is never touched; the answer is `taken` with a free name to use instead.

- **Stored in HLIX Repos:** read with your hlix sign-in. The folder is a git repository with the project's history, on the project's default branch, and it is bound to the project, so [`hlix pull`, `hlix push` and `hlix sync`](/reference/cli/sync/) work in it at once. The folder's own git config also gets a credential helper for the HLIX Repos host only (see `hlix repo credential`), so plain `git push` and `git pull` need no token. The sign-in is not saved in the folder.
- **Stored on GitHub:** cloned with your own git, your keys and credential helper, as `hlix local clone` does.

`--open` also opens the clone as a project of this device, linked to the cloud project. This is what the desktop app's **Clone from hlix cloud** runs.

With `--json`, every line is one JSON object: step lines `{"event":"step","step":"reading|downloading|writing|binding|opening","files":N}`, then the answer `{schemaVersion, command, data}` whose `data.outcome` is one of `cloned`, `no_code`, `taken`, `canceled`, `busy`, `auth_failed`, `not_found`, `network`, `target_exists`, `invalid_name`, `invalid_parent`, `git_missing`, `failed` or `cloned_not_opened`. The exit code is 0 only for `cloned`.

## `hlix repo credential`

```bash
hlix repo credential get|store|erase --project <id>
```

Git's [credential helper](https://git-scm.com/docs/gitcredentials) for the HLIX Repos remote of a project. Git runs it; a person does not. hlix writes it into a folder's own git config as `credential.https://<host>.helper`, for the HLIX Repos host alone (never `--global`, never another host), when a folder is cloned, imported, or synced with `hlix sync`. `get` answers a request for that host with a short-lived token on stdout, following [git's credential protocol](https://git-scm.com/docs/git-credential); `store` and `erase` do nothing. No token is ever written into `.git/config` or a remote URL.

## If a command fails

- `not_found` — no project in the workspace has that ID or name. Check `hlix repo list`, or name the workspace: `workspace/name`.
- `invalid_usage` — two projects share the name, or both a directory and `--into` were given. Use the project ID.
- `unauthenticated` — the sign-in is missing or has expired. Run `hlix login`.