Skip to content
An 8-bit style, two-dimensional file directory icon features branching lines with geometric nodes to represent git branches, a small gear for settings, and a tag icon for version tags. A directional arrow points toward a repository box to indicate shallow cloning, while a dashed outline marks an ignored file. The artwork uses five solid corporate colors in a flat, minimalist design with no background or gradients, created for a 128x128 size.

Git

The git helper provides a thin wrapper around invoking the git executable for repository operations.

Resolves the default branch, typically main or master, in the repository.

const df = await git.defaultBranch();

Gets the last tag in the repository.

const tag = await git.lastTag();

Gets the current branch of the repository.

const branchName = await git.branch();

Executes a git command in the repository and returns the stdout.

const output = await git.exec(["status"]);

Lists the branches in the git repository.

const branches = await git.listBranches();

Finds specific files in the git repository.

const files = await git.listFiles("modified");

Gets the diff for the current repository state.

const diffOutput = await git.diff({ staged: true });

Lists the commits with various filters. Includes sha, author, date, message and file names.

const commits = await git.log({ ... });

Lists the files changed in the last commit.

const changedFiles = await git.changedFiles({ ... });

Since GenAIScript uses git, it already supports the .gitignore instructions. You can also provide additional repository-wide ignore through the .gitignore.genai file at the workspace root.

.gitignore.genai
**/genaiscript.d.ts

You can create cached shallow clones of repositories to work on multiple repositories. The shallowClone method return a git client instance.

The clones are created under the .genaiscript/git/... directory and are cached based on the repository/branch/commit information.

const clone = await git.shallowClone("microsoft/genaiscript");

You can provide options to force the cloning and/or running the install command after cloning.

const clone = await git.shallowClone("microsoft/genaiscript", {
force: true,
install: true,
});

Use git.client to open a git client on a different working directory. This allows you to run git commands on a different repository.

const other = git.client("/path/to/other/repo");
const branch = await other.branch();