Git Sync
1. Getting Started

Configuration & Setup

Configuration & Setup

After publishing the configuration with php artisan vendor:publish --tag="git-sync-config", all settings live in config/git-sync.php:

return [
    /*
    |--------------------------------------------------------------------------
    | Default Git Provider
    |--------------------------------------------------------------------------
    | Supported: "github", "bitbucket"
    */
    'default_provider' => env('GIT_SYNC_PROVIDER', 'github'),

    /*
    |--------------------------------------------------------------------------
    | Target Branches
    |--------------------------------------------------------------------------
    | The branches that are allowed to be selected as a target for the PR.
    */
    'target_branches' => ['main', 'master', 'develop', 'staging'],

    /*
    |--------------------------------------------------------------------------
    | Provider Configurations
    |--------------------------------------------------------------------------
    */
    'providers' => [
        'github' => [
            'token' => env('GITHUB_TOKEN'),
            // Format: 'owner/repo'
            'repository' => env('GITHUB_REPOSITORY'),
        ],
        'bitbucket' => [
            'username' => env('BITBUCKET_USERNAME'),
            // App Password or Workspace Token
            'password' => env('BITBUCKET_PASSWORD'),
            'workspace' => env('BITBUCKET_WORKSPACE'),
            'repository' => env('BITBUCKET_REPOSITORY'),
        ],
    ],
];

Environment Variables (.env)

Depending on whether your project is hosted on GitHub or Bitbucket, add the corresponding variables to your .env file:

Option A: GitHub Configuration

GIT_SYNC_PROVIDER=github
GITHUB_TOKEN=ghp_your_personal_access_token
GITHUB_REPOSITORY=your-organization/your-repository

Option B: Bitbucket Configuration

GIT_SYNC_PROVIDER=bitbucket
BITBUCKET_USERNAME=your_bitbucket_username
BITBUCKET_PASSWORD=your_bitbucket_app_password
BITBUCKET_WORKSPACE=your-workspace-slug
BITBUCKET_REPOSITORY=your-repo-slug

How Service Container Resolution Works

GitSyncServiceProvider binds Tokomono\GitSync\Contracts\GitProviderInterface in the Laravel service container based on config('git-sync.default_provider'):

  • When default_provider is 'github', Laravel resolves Tokomono\GitSync\Services\GitHubProvider.
  • When default_provider is 'bitbucket', Laravel resolves Tokomono\GitSync\Services\BitbucketProvider.
  • If an unsupported provider string is configured, GitSyncServiceProvider throws an Exception: Unsupported Git provider config: {provider}. You can bind your own implementation to GitProviderInterface.