Skip to main content
The Git API provides endpoints for Git operations including cloning repositories, managing branches, committing changes, and synchronizing with remote repositories.

Repository Operations

Clone Repository

Clone a Git repository to a specified path.
Request Body:
Parameters:

Get Repository Status

Get the current Git status of a repository.
Response:
File Status Values:
  • Unmodified - No changes
  • Untracked - New file not tracked
  • Modified - File changed
  • Added - File staged for commit
  • Deleted - File deleted
  • Renamed - File renamed
  • Copied - File copied
  • Updated but unmerged - Merge conflict

Get Commit History

Retrieve the commit history of a repository.
Response:

Branch Management

List Branches

Get all branches in the repository.
Response:

Create Branch

Create a new branch.
Request Body:

Checkout Branch

Switch to a different branch.
Request Body:

Delete Branch

Delete a branch from the repository.
Request Body:

Staging and Committing

Add Files

Add files to the Git staging area.
Request Body:
Parameters:

Commit Changes

Commit staged changes to the repository.
Request Body:
Parameters: Response:

Remote Operations

Pull Changes

Pull changes from the remote repository.
Request Body:
Parameters:

Push Changes

Push local commits to the remote repository.
Request Body:
Parameters:

Git Workflows

Complete Feature Workflow

Here’s a typical workflow for developing a feature:

Best Practices

Always check the repository status before committing to understand what changes will be included.
  • Use descriptive commit messages
  • Pull before pushing to avoid conflicts
  • Use feature branches for new development
  • Provide authentication credentials securely (use environment variables)
  • Handle merge conflicts appropriately
  • Check ahead and behind counts in status to track synchronization

Authentication

Never hardcode Git credentials. Use environment variables or secure secret management.
For private repositories, provide credentials:
For GitHub, use Personal Access Tokens instead of passwords.

Example Usage

Prefer using the official Daytona SDKs over direct API calls for better type safety and error handling.