---
title: "Freestyle Git"
description: "Create and manage multi-tenant Git repositories for user- and agent-generated code."
url: "/docs/git"
---

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

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

const { repo } = await freestyle.git.repos.create();

console.log(repo.id);
```


## Clone A Repository

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

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

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

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

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

Use the token with native Git:

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


## Read Files By API

```ts
const ref = freestyle.git.repos.ref({ repoId: repo.id });

const file = await ref.contents.get({ path: "README.md" });
const content = atob(file.content);

console.log(content);
```
