A Laravel package that enables developers to commit and push code changes to Git with a single command.
Global Installation (Recommended for Personal Use):
# Install once
composer global require aaronidikko/laravel-git-sync
# Use anywhere!
git-sync # Default chore message
git-sync -m "New feature" # Custom messagePer-Project Installation (Recommended for Teams):
# Install in your Laravel project
composer require aaronidikko/laravel-git-sync
# Use it!
composer sync # Default chore message
php artisan git:sync -m "New feature" # Custom message- Dual Installation Modes: Install globally or per-project
- Single command to stage, commit, and push changes
- Custom or auto-generated timestamped commit messages
- Multiple workflows: commit-only, push-only, dry-run modes
- Comprehensive error handling for common Git scenarios
- Configurable commit message prefixes and timestamp formats
- Automatic branch detection and upstream setup
- Verbose mode for detailed output
- Works in non-Laravel projects (when installed globally)
You can install this package in two ways:
Install in a specific Laravel project:
cd your-laravel-project
composer require aaronidikko/laravel-git-syncBenefits:
- Team members get the package automatically via
composer install - Configuration can be version-controlled
- Consistent across the team
Usage:
composer sync # Quick sync
php artisan git:sync # AlternativeInstall once, use everywhere:
composer global require aaronidikko/laravel-git-syncMake sure ~/.composer/vendor/bin (or ~/.config/composer/vendor/bin on some systems) is in your PATH.
Benefits:
- Install once, use in all Laravel projects
- Works even in non-Laravel git repositories
- Quick access via
git-synccommand
Usage:
git-sync # From any Laravel project
git-sync -m "New feature" # Works globally
composer sync # Also works if installed per-projectIf you installed per-project and want to customize settings:
php artisan vendor:publish --tag=git-sync-configThis creates config/git-sync.php where you can customize commit message format, prefixes, etc.
| Feature | Global Installation | Per-Project Installation |
|---|---|---|
| Command | git-sync |
composer sync or php artisan git:sync |
| Install Once | ✅ Yes, use everywhere | ❌ No, per project |
| Team Sharing | ❌ Manual install for each | ✅ Auto via composer.json |
| Config File | ❌ Not available | ✅ Customizable |
| Works in Non-Laravel | ✅ Yes, basic git sync | ❌ No |
| Command Length | ✅ Shortest (git-sync) |
|
| Best For | Personal projects, quick use | Team projects, consistency |
The package provides three ways to sync your changes:
Simplest and fastest option:
# Default chore message with timestamp
git-sync
# With custom message
git-sync -m "Add new feature"
git-sync --message="Fix authentication bug"
# Other options
git-sync --verbose
git-sync --commit-only
git-sync --dry-run
git-sync --branch=developWorks with both installation methods:
# Default chore message
composer sync
# With custom message (note the -- separator for per-project)
composer sync -- -m "New Feature"
composer sync -- --message="Fix authentication bug"
# Other options
composer sync -- --verbose
composer sync -- --commit-only
composer sync -- --dry-runTraditional Laravel command:
# Default chore message
php artisan git:sync
# With custom message
php artisan git:sync -m "Add new feature"
php artisan git:sync --message="Fix bug"
# Other options
php artisan git:sync --verbose
php artisan git:sync --commit-only
php artisan git:sync --dry-runAll commands will:
- Stage all changes (
git add .) - Commit with message like
chore: 2025-10-25 09:30(or your custom message) - Push to the current branch
| Installation Type | Recommended Command | Why? |
|---|---|---|
| Global | git-sync |
Shortest, fastest |
| Per-Project (Solo) | composer sync |
Quick, no artisan prefix |
| Per-Project (Team) | php artisan git:sync |
Clear, discoverable |
All commands support the same options:
| Option | Shorthand | Description |
|---|---|---|
--message="text" |
-m "text" |
Custom commit message |
--commit-only |
- | Commit without pushing |
--push-only |
- | Push without committing |
--dry-run |
- | Preview actions without executing |
--verbose |
- | Show detailed output |
--branch=name |
- | Push to specific branch |
Examples with git-sync (Global):
git-sync -m "Add new feature"
git-sync --commit-only
git-sync --dry-run
git-sync --verbose
git-sync --branch=developExamples with composer sync (Per-Project):
composer sync -- -m "Add new feature"
composer sync -- --commit-only
composer sync -- --dry-run
composer sync -- --branch=developExamples with artisan (Per-Project):
php artisan git:sync -m "Add new feature"
php artisan git:sync --commit-only
php artisan git:sync --dry-run
php artisan git:sync --branch=developAfter publishing the config file, you can customize settings in config/git-sync.php:
return [
// Default prefix for auto-generated commit messages
'default_commit_prefix' => env('GIT_SYNC_COMMIT_PREFIX', 'chore'),
// Timestamp format for commit messages
'timestamp_format' => env('GIT_SYNC_TIMESTAMP_FORMAT', 'Y-m-d H:i'),
// Default remote repository
'default_remote' => env('GIT_SYNC_REMOTE', 'origin'),
// Safety checks
'safety_checks' => [
'max_file_size' => 10, // MB
'protected_branches' => ['main', 'master', 'production'],
],
];You can also configure via .env:
GIT_SYNC_COMMIT_PREFIX=feat
GIT_SYNC_TIMESTAMP_FORMAT="Y-m-d H:i:s"
GIT_SYNC_REMOTE=originWith Global Installation:
# Quick save with timestamp
git-sync
# Save with meaningful message
git-sync -m "Implement user authentication"
# Check what would happen first
git-sync --dry-run
# Commit locally without pushing
git-sync --commit-onlyWith Per-Project Installation:
# Quick save
composer sync
# With message
composer sync -- -m "Implement user authentication"
# Or use artisan
php artisan git:sync -m "Implement user authentication"Global:
git-sync -m "Add feature X"
git-sync --branch=feature/new-ui -m "Update UI components"Per-Project:
composer sync -- -m "Add feature X"
php artisan git:sync --branch=feature/new-ui -m "Update UI components"If you have the package installed globally, it works even in non-Laravel git repositories with basic git sync functionality:
cd any-git-project
git-sync -m "Quick update"Note: Configuration options (custom prefixes, timestamp format, etc.) only work in Laravel projects with the config file published.
The package handles common Git scenarios:
- Not a Git repository: Prompts to initialize Git
- No remote configured: Shows how to add a remote
- No upstream branch: Automatically sets upstream
- Remote has changes: Suggests pulling first
- No changes to commit: Informs you the working tree is clean
- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x
- Git installed on your system
Run the test suite:
composer testContributions are welcome! Please feel free to submit a Pull Request.
This package is open-sourced software licensed under the MIT license.
Created by Aaron Idikko
If you find this package helpful, please consider:
- Starring the repository on GitHub
- Sharing it with others
- Reporting issues or suggesting features
- Initial release
- Basic git sync functionality
- Custom and auto-generated commit messages
- Multiple workflow modes
- Comprehensive error handling
- Configuration options
- Test suite