Using Git with Freestyle
Learn how to use Freestyle's Git API to manage and deploy code from Git repositories
Git with Freestyle
Freestyle provides a comprehensive Git API that enables you to manage Git repositories, control access permissions, and set up automation triggers. This document covers everything you need to know about using Git with Freestyle.
Overview
Freestyle's Git support allows you to:
- Create and manage Git repositories
- Control repository access with identity-based permissions
- Set up automation triggers for repository events
- Integrate with CI/CD workflows
- Deploy applications directly from Git
Git Repositories
Creating a Repository
To create a new Git repository:
Note that the name of the repository is optional and is for display purposes only. The actual repository ID is generated by Freestyle.
Create a public repository:
Create a repository from an existing Git repository
Note that there is currently no support for private repositories from outside of Freestyle.
After creating a repository, you can push code to it using the standard Git CLI:
Listing Repositories
You can list all repositories associated with your account:
Deleting Repositories
When you no longer need a repository, you can delete it:
Identity and Access Management
Freestyle uses identity-based access control for Git repositories. This allows you to create separate identities for different purposes (e.g., CI/CD, team members) and grant them specific permissions.
Creating an Identity
Managing Access Tokens
Each identity can have one or more access tokens used for authentication:
Managing Permissions
You can grant identities different levels of access to your repositories:
Git Triggers
Git triggers allow you to automate actions when certain events occur in your repositories, such as a push to a specific branch.
Creating a Trigger
Listing Triggers
Deleting Triggers
Authentication for Git Operations
To authenticate Git CLI operations with Freestyle, you'll need to configure Git to use your access token:
Alternatively, you can use SSH keys for authentication, which is recommended for automated systems and continuous integration.
Continuous Integration Example
Here's an example of how to set up a CI workflow with Freestyle Git:
- Create a dedicated Git identity for CI:
- Grant the identity write access to your repository:
- Set up a webhook trigger to notify your CI system:
- Configure your CI system to clone the repository, run tests, and deploy if successful.
Deployment with Git
Freestyle makes it easy to deploy applications directly from Git repositories:
API Reference
For complete details on all available Git API endpoints, refer to the API Reference section.
Best Practices
- Use dedicated identities for different purposes (CI/CD, team members, etc.)
- Regularly rotate access tokens for security
- Limit permissions to the minimum required access level
- Use webhooks to integrate with your existing CI/CD workflows
- Secure sensitive variables using environment variables rather than committing them to your repository