LogoFreestyle

Getting Started with Git

For a high-level overview of Freestyle Git, its features and why to use it, see About Freestyle Git.

Sign up at dash.freestyle.sh, create an api key, and configure it in your environment.

.env
FREESTYLE_API_KEY=your-api-key
npm i freestyle-sandboxes

Quick Start

Create a Repository

import { freestyle } from "freestyle-sandboxes";

const { repo } = await freestyle.git.repos.create();
console.log(repo.id); // your new repo ID

Clone It Locally

Create an identity and access token, then clone the repository with git.

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}`);
git clone https://x-access-token:<token>@git.freestyle.sh/<repo-id>

Read a File

You can also read files via the API without cloning.

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);

Next Steps

On this page

Freestyle AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details with the official documentation.

How can I help?

Ask me about Freestyle while you browse the docs.