# Git Integration - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/guides/sandbox-git-integration

# Git Integration

Novita Sandbox exposes `sandbox.git` helpers for common repository workflows such as cloning, branching, committing, pulling, pushing, managing remotes, and configuring Git.

##

[​](#authentication-and-identity)

Authentication and identity

###

[​](#inline-credentials)

Inline credentials

For private HTTPS repositories, pass both a username and password/token directly into operations such as `push`, `pull`, or `clone`.

JavaScript & TypeScript

Python

```
import { Sandbox } from 'novita-sandbox'

const sandbox = await Sandbox.create()

await sandbox.git.push(repoPath, {
username: process.env.GIT_USERNAME,
password: process.env.GIT_TOKEN,
})

await sandbox.git.pull(repoPath, {
username: process.env.GIT_USERNAME,
password: process.env.GIT_TOKEN,
})
```

###

[​](#authenticate-once-with-the-git-credential-helper)

Authenticate once with the Git credential helper

You can use `dangerouslyAuthenticate()` in JavaScript or `dangerously_authenticate()` in Python to store credentials inside the sandbox credential helper.

Credentials are written to disk inside the sandbox and can be read by anything with sandbox access.

Credentials may be stored for GitHub by default or for a custom HTTPS host.

JavaScript & TypeScript

Python

```
await sandbox.git.dangerouslyAuthenticate({
username: process.env.GIT_USERNAME,
password: process.env.GIT_TOKEN,
})

await sandbox.git.dangerouslyAuthenticate({
username: process.env.GIT_USERNAME,
password: process.env.GIT_TOKEN,
host: 'git.example.com',
protocol: 'https',
})

await sandbox.git.clone('https://git.example.com/org/repo.git', {
path: '/home/user/repo',
})

await sandbox.git.push('/home/user/repo')
```

###

[​](#keep-credentials-in-the-remote-url)

Keep credentials in the remote URL

By default, credentials are removed from the remote URL after clone. To retain them in `.git/config`, set `dangerouslyStoreCredentials: true` (JS) or `dangerously_store_credentials=True` (Python).

Credentials kept in a remote URL remain in repo config and are readable by sandbox processes.

JavaScript & TypeScript

Python

```
await sandbox.git.clone('https://git.example.com/org/repo.git', {
path: '/home/user/repo',
username: process.env.GIT_USERNAME,
password: process.env.GIT_TOKEN,
})

await sandbox.git.clone('https://git.example.com/org/repo.git', {
path: '/home/user/repo',
username: process.env.GIT_USERNAME,
password: process.env.GIT_TOKEN,
dangerouslyStoreCredentials: true,
})
```

##

[​](#configure-commit-identity)

Configure commit identity

You can use `configureUser` (JS) or `configure_user` (Python) to set commit author details globally or locally for a repository.

JavaScript & TypeScript

Python

```
await sandbox.git.configureUser('Novita Bot', 'bot@example.com')

await sandbox.git.configureUser('Novita Bot', 'bot@example.com', {
scope: 'local',
path: repoPath,
})
```

##

[​](#clone-repositories)

Clone repositories

Supported clone options include destination path, branch selection, depth, username, password, and credential-storage behavior.

JavaScript & TypeScript

Python

```
await sandbox.git.clone(repoUrl, {
path: repoPath,
})

await sandbox.git.clone(repoUrl, {
path: repoPath,
branch: 'main',
})

await sandbox.git.clone(repoUrl, {
path: repoPath,
depth: 1,
})
```

##

[​](#check-repository-status-and-branches)

Check repository status and branches

You can use `status()` to inspect current branch, ahead/behind counts, and file status.
You can use `branches()` to get the branch list and current branch.

JavaScript & TypeScript

Python

```
const status = await sandbox.git.status(repoPath)
console.log(status.currentBranch)
console.log(status.ahead)
console.log(status.behind)
console.log(status.fileStatus)

const branches = await sandbox.git.branches(repoPath)
console.log(branches.currentBranch)
console.log(branches.branches)
```

##

[​](#create-switch-and-delete-branches)

Create, switch, and delete branches

JavaScript & TypeScript

Python

```
await sandbox.git.createBranch(repoPath, 'feature/new-docs')

await sandbox.git.checkoutBranch(repoPath, 'main')

await sandbox.git.deleteBranch(repoPath, 'feature/old-docs')

await sandbox.git.deleteBranch(repoPath, 'feature/stale-docs', {
force: true,
})
```

##

[​](#stage-and-commit-changes)

Stage and commit changes

You can use `add` to stage all changes or selected files.
You can use `commit` to create commits. Options include custom author name, author email, and empty commits.

JavaScript & TypeScript

Python

```
await sandbox.git.add(repoPath)

await sandbox.git.commit(repoPath, 'Initial commit')

await sandbox.git.add(repoPath, {
files: ['README.md', 'src/index.ts'],
})

await sandbox.git.commit(repoPath, 'Docs sync', {
authorName: 'Novita Bot',
authorEmail: 'bot@example.com',
allowEmpty: true,
})
```

##

[​](#pull-and-push)

Pull and push

`push` and `pull` can use the configured upstream by default. You can also specify remote, branch, and upstream configuration.

JavaScript & TypeScript

Python

```
await sandbox.git.push(repoPath)

await sandbox.git.pull(repoPath)

await sandbox.git.push(repoPath, {
remote: 'origin',
branch: 'main',
setUpstream: true,
})

await sandbox.git.pull(repoPath, {
remote: 'origin',
branch: 'main',
})
```

##

[​](#manage-remotes)

Manage remotes

You can use `remoteAdd` (JS) or `remote_add` (Python) to add remotes, optionally fetch after adding, or overwrite an existing remote.

JavaScript & TypeScript

Python

```
await sandbox.git.remoteAdd(repoPath, 'origin', repoUrl)

await sandbox.git.remoteAdd(repoPath, 'origin', repoUrl, {
fetch: true,
})

await sandbox.git.remoteAdd(repoPath, 'origin', repoUrl, {
overwrite: true,
})
```

##

[​](#git-configuration)

Git configuration

You can use `setConfig` / `set_config` and `getConfig` / `get_config` to manage Git settings globally or per repository.

JavaScript & TypeScript

Python

```
await sandbox.git.setConfig('pull.rebase', 'false')

const value = await sandbox.git.getConfig('pull.rebase')

await sandbox.git.setConfig('pull.rebase', 'false', {
scope: 'local',
path: repoPath,
})

const localValue = await sandbox.git.getConfig('pull.rebase', {
scope: 'local',
path: repoPath,
})
```

Last modified on June 4, 2026
