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.
FREESTYLE_API_KEY=your-api-keynpm i freestyle-sandboxesQuick Start
Create a Repository
import { freestyle } from "freestyle-sandboxes";
const { repo } = await freestyle.git.repos.create();
console.log(repo.id); // your new repo IDClone 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);