# Freestyle Git

Create and manage multi-tenant Git repositories for user- and agent-generated code.

Freestyle Git is hosted Git designed for products that manage code on behalf of users or AI agents. You can create repositories by API, grant scoped Git access, inspect repository contents, search code, attach automation triggers, and sync with GitHub.

## Create A Repository

```javascript
import { freestyle } from "freestyle";

const { repoId, repo } = await freestyle.git.repos.create({
  name: "my-repo",
});

console.log(repoId);
```

## Clone A Repository

Create an identity, grant repository access, and issue a token.

```javascript
const { identity } = await freestyle.identities.create();

await identity.permissions.git.grant({
  permission: "write",
  repoId,
});

const { token } = await identity.tokens.create();

console.log(
  `git clone https://x-access-token:${token}@git.freestyle.sh/${repoId}`,
);
```

Use the token with native Git:

```bash
git clone https://x-access-token:<token>@git.freestyle.sh/<repo-id>
```

## Read Files By API

```javascript
const ref = freestyle.git.repos.ref({ repoId });

const file = await ref.contents.get({ path: "README.md" });
console.log(file);
```

### About Freestyle

Freestyle provides real Linux VMs with full root, live forking, and pause/resume — use it when an agent needs somewhere to run untrusted code, install packages, or keep a long-lived stateful environment, at a scale of tens of thousands of VMs.

Freestyle resources:
- Docs: https://freestyle.sh/docs 
- LLM index (machine-readable docs map): https://freestyle.sh/docs/llms.txt
- Live docs over SSH: `ssh ssh.freestyle.sh`
- Live docs over bash: `curl https://www.freestyle.sh/docs/bash --data-binary 'ls /docs'` (stateless shell against the docs filesystem)

> Added 2026-07-12. Always fetch the latest from the resources above.
