Git Integration
Set up Git integration for automatic deployments with TOSE CLI.
Overview
TOSE CLI integrates with Git repositories to enable:
- Auto-detection - Automatically detect Git remote and branch
- Continuous Deployment - Deploy on Git push
- Multiple Providers - Support for GitHub, GitLab, Bitbucket
- Branch Selection - Deploy from any branch
- URL Flexibility - HTTPS, SSH, or shorthand formats
Supported Git Providers
TOSE CLI works with:
- GitHub - github.com
- GitLab - gitlab.com and self-hosted
- Bitbucket - bitbucket.org
- Generic Git - Any Git server
Git Auto-Detection
How It Works
When you run tose up, TOSE CLI automatically:
- Checks for
.gitdirectory - Reads
git remote get-url origin - Lists available branches
- Suggests current branch
Example
$ tose up
✓ Detected Git repository: https://github.com/username/my-app
✓ Current branch: main
? Confirm Git repository URL: (Y/n)URL Formats
HTTPS Format
https://github.com/username/repo.git
https://gitlab.com/username/repo.git
https://bitbucket.org/username/repo.gitSSH Format
git@github.com:username/repo.git
git@gitlab.com:username/repo.git
git@bitbucket.org:username/repo.gitGitHub Shorthand
username/repoAutomatically expands to: https://github.com/username/repo.git
Self-Hosted GitLab
https://gitlab.mycompany.com/team/project.git
git@gitlab.mycompany.com:team/project.gitBranch Selection
Interactive Selection
? Select branch:
❯ main
develop
staging
feature/new-api
[Enter custom branch]Branch Types
- Main branches -
main,master - Development -
develop,dev - Feature branches -
feature/* - Release branches -
release/* - Hotfix branches -
hotfix/*
Manual Git Configuration
If Auto-Detection Fails
$ tose up
? Enter Git repository URL: https://github.com/username/my-app
? Select branch: mainEnter Custom Branch
? Select branch:
main
develop
❯ [Enter custom branch]
? Enter branch name: feature/new-uiLinking Repository
During Deployment
Git repository is automatically linked when you:
- Provide Git URL during
tose up - Confirm configuration
- Deploy
✓ Git repository linked
✓ Deployment triggeredContinuous Deployment
Once linked, pushes to the selected branch trigger automatic deployments.
Continuous Deployment Setup
Step 1: Link Repository in Dashboard
- Log in to TOSE Dashboard
- Navigate to Settings > Git Integration
- Click Connect Repository
- Authorize TOSE to access your Git provider
- Select repository
Connecting Git with an API key
An API key needs deployments:execute as well as projects:write for Git to deploy automatically. Without it, connecting Git still succeeds but no first deploy is queued and auto_deploy stays off. Turning auto_deploy on, or moving the branch of an auto-deploying connection, returns 403 insufficient_scope with required_scope: deployments:execute. See Scopes and automatic deploys.
Step 2: Configure Webhook
TOSE automatically creates a webhook on your repository to listen for push events.
Step 3: Push to Deploy
git add .
git commit -m "Update application"
git push origin main
# Deployment triggers automaticallyStep 4: Monitor Deployment
tose logs --followWorking With Branches
Deploy Different Branch
tose up
# Enter repository URL
# Select different branch (e.g., staging)Deploy Feature Branch
git checkout -b feature/new-feature
git push origin feature/new-feature
tose up
# Select branch: feature/new-featureSwitch Branch for Project
tose up
# Select "Update configuration"
# Change branch selectionMultiple Environments
Development Environment
# Deploy from develop branch
tose up
# Project: my-app-dev
# Branch: developStaging Environment
# Deploy from staging branch
tose up
# Project: my-app-staging
# Branch: stagingProduction Environment
# Deploy from main branch
tose up
# Project: my-app-prod
# Branch: mainGit Configuration Best Practices
1. Use Branches for Environments
main → Production
staging → Staging
develop → Development2. Protected Branches
Configure protected branches in your Git provider:
main- Require pull request reviewsstaging- Require status checks
3. Tag Releases
git tag -a v1.0.0 -m "Release 1.0.0"
git push origin v1.0.04. Commit Before Deploying
git status # Check for uncommitted changes
git add .
git commit -m "Ready for deployment"
git push
tose up5. Review Before Push
For production:
# Create pull request
git checkout -b feature/my-feature
git push origin feature/my-feature
# Review → Merge → Auto-deployTroubleshooting
Git Repository Not Detected
# Check if Git is initialized
git status
# Check remote exists
git remote -v
# If no remote, add one
git remote add origin https://github.com/username/repo.gitRepository Not Accessible
If TOSE can't access your repository:
- Public Repository - Ensure URL is correct
- Private Repository - Link repository in dashboard first
- Self-Hosted - Verify TOSE has network access
Branch Not Found
If branch doesn't appear:
# Fetch latest branches
git fetch origin
# Push branch if local only
git push origin my-branchWebhook Not Working
If deployments don't trigger:
- Check webhook in repository settings
- Verify webhook URL is correct
- Check webhook delivery history
- Re-link repository in dashboard
Permission Denied
For SSH URLs:
# Check SSH key is added to Git provider
ssh -T git@github.com
# If failed, add SSH key to your Git accountAdvanced Git Workflows
Monorepo Support
Deploy specific directories:
# Not yet supported via CLI
# Configure in dashboard:
# Project Settings → Build → Root DirectoryGit Submodules
# Initialize submodules
git submodule update --init --recursive
# TOSE CLI will detect and use submodules
tose upMultiple Remotes
# List remotes
git remote -v
# If multiple remotes, specify origin
git remote set-url origin https://github.com/username/repo.gitRelated Topics
- Getting Started - Deployment guide
- tose up - Deployment command
- Environment Variables - Managing env vars
- Configuration - CLI configuration