PHPackages                             aaronidikko/laravel-git-sync - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aaronidikko/laravel-git-sync

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aaronidikko/laravel-git-sync
============================

A Laravel package to commit and push changes to Git with one command.

v1.2.1(6mo ago)11753MITPHPPHP ^8.2

Since Oct 26Pushed 5mo agoCompare

[ Source](https://github.com/Aarondio/laravel-git-sync)[ Packagist](https://packagist.org/packages/aaronidikko/laravel-git-sync)[ RSS](/packages/aaronidikko-laravel-git-sync/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (8)Used By (0)

Laravel Git Sync
================

[](#laravel-git-sync)

A Laravel package that enables developers to commit and push code changes to Git with a single command.

[![Latest Version on Packagist](https://camo.githubusercontent.com/33567872f035762b0d1e7386bc651bf3c6ae2a1b13a426db7f291fdaa91df356/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6161726f6e6964696b6b6f2f6c61726176656c2d6769742d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aaronidikko/laravel-git-sync)[![Total Downloads](https://camo.githubusercontent.com/6ba3129880fd71246374f420199344ebaa78bb35327f276286e9c6207d4aa885/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6161726f6e6964696b6b6f2f6c61726176656c2d6769742d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aaronidikko/laravel-git-sync)

Quick Start
-----------

[](#quick-start)

**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 message
```

**Note:** If you get "command not found: git-sync", see the [PATH setup instructions](#troubleshooting) below.

**Per-Project Installation (Recommended for Teams):**

```
# Install in your Laravel project
composer require aaronidikko/laravel-git-sync

# Use it immediately!
php artisan git:sync                     # Default chore message
php artisan git:sync -m "New feature"    # Custom message
```

**Optional:** Run `php artisan git:sync:install` to enable the shorter `composer sync` command. [Details below](#optional-add-composer-script-shortcut).

Features
--------

[](#features)

- **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, pull-before-push, dry-run modes
- **Comprehensive error handling** for common Git scenarios
- **Configurable** commit message prefixes and timestamp formats
- **Automatic branch detection** and upstream setup
- **Pull integration**: Optionally pull remote changes before pushing
- **Verbose mode** for detailed output
- **Works in non-Laravel projects** (when installed globally)

Installation
------------

[](#installation)

You can install this package in two ways:

### Option 1: Per-Project Installation (Recommended for Teams)

[](#option-1-per-project-installation-recommended-for-teams)

Install in a specific Laravel project:

```
cd your-laravel-project
composer require aaronidikko/laravel-git-sync
```

**Benefits:**

- Team members get the package automatically via `composer install`
- Configuration can be version-controlled
- Consistent across the team

**Optional: Enable `composer sync` (One-Time Setup)**

The `php artisan git:sync` command is **automatically available** after installation. The install command below is **optional** and only adds a convenient `composer sync` shortcut.

Run this command once to add a `composer sync` shortcut to your project:

```
php artisan git:sync:install
```

**What it does:**

- Adds `"sync": "@php artisan git:sync"` to your project's `composer.json`
- Creates a shortcut: `composer sync` → calls → `php artisan git:sync`
- Does **not** affect the `php artisan git:sync` command (always works)

After running install, you can use:

```
composer sync                   # Shortcut (calls php artisan git:sync)
composer sync -- -m "message"   # With custom message
composer sync -- --pull         # With options
```

**Available Commands:**

```
composer sync                   # Only if you ran git:sync:install
php artisan git:sync            # Always available (no setup needed)
vendor/bin/git-sync             # Always available (no setup needed)
```

### Option 2: Global Installation (Recommended for Personal Use)

[](#option-2-global-installation-recommended-for-personal-use)

Install once, use everywhere:

```
composer global require aaronidikko/laravel-git-sync
```

**Important: Add Composer's bin directory to your PATH**

After installation, you need to add Composer's global bin directory to your PATH to use the `git-sync` command:

**Step 1: Find your Composer bin directory**

```
composer global config bin-dir --absolute
```

This is usually `~/.composer/vendor/bin` or `~/.config/composer/vendor/bin`

**Step 2: Add to PATH based on your shell**

For **Bash** (add to `~/.bashrc` or `~/.bash_profile`):

```
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```

For **Zsh** (add to `~/.zshrc`):

```
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```

For **Fish** (add to `~/.config/fish/config.fish`):

```
fish_add_path ~/.composer/vendor/bin
```

**Step 3: Verify installation**

```
which git-sync
# Should output: /Users/yourusername/.composer/vendor/bin/git-sync

git-sync --help
# Should show the help message
```

**Benefits:**

- Install once, use in all Laravel projects
- Works even in non-Laravel git repositories
- Quick access via `git-sync` command

**Usage:**

```
git-sync                        # From any directory
git-sync -m "New feature"       # Works globally
```

### Publishing Configuration (Per-Project Only)

[](#publishing-configuration-per-project-only)

If you installed per-project and want to customize settings:

```
php artisan vendor:publish --tag=git-sync-config
```

This creates `config/git-sync.php` where you can customize commit message format, prefixes, etc.

### Installation Comparison

[](#installation-comparison)

FeatureGlobal InstallationPer-Project Installation**Command**`git-sync``php artisan git:sync` or `vendor/bin/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`)⚠️ Longer**Best For**Personal projects, quick useTeam projects, consistencyUsage
-----

[](#usage)

The package provides different commands based on installation type:

### 1. Global Command (If Installed Globally)

[](#1-global-command-if-installed-globally)

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 --pull
git-sync --dry-run
git-sync --branch=develop
```

### 2. Artisan Command (Per-Project Installation)

[](#2-artisan-command-per-project-installation)

Standard 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 --pull
php artisan git:sync --dry-run
```

### 3. Direct Binary (Per-Project Installation)

[](#3-direct-binary-per-project-installation)

Alternative for per-project installations:

```
# Default chore message
vendor/bin/git-sync

# With custom message
vendor/bin/git-sync -m "Add new feature"

# Other options
vendor/bin/git-sync --verbose
vendor/bin/git-sync --pull
```

### Optional: Add Composer Script Shortcut

[](#optional-add-composer-script-shortcut)

**Note:** The `php artisan git:sync` command works immediately after installation. This section is **optional** and only adds a shorter `composer sync` alias.

To enable `composer sync` in your project, run this one-time setup command:

```
php artisan git:sync:install
```

This automatically adds `"sync": "@php artisan git:sync"` to your project's `composer.json`, creating a shortcut.

Then use:

```
composer sync                      # Calls php artisan git:sync
composer sync -- -m "Custom message"
composer sync -- --pull
```

### How It Works

[](#how-it-works)

All commands will:

1. Stage all changes (`git add .`)
2. Commit with message like `chore: 2025-10-25 09:30` (or your custom message)
3. Push to the current branch

### Which Command Should I Use?

[](#which-command-should-i-use)

Installation TypeRecommended CommandWhy?Global`git-sync`Shortest, fastestPer-Project`php artisan git:sync`Standard Laravel conventionPer-Project (Alt)`vendor/bin/git-sync`Direct binary accessPer-Project (Optional)`composer sync`Requires running `git:sync:install` first### Understanding the Commands

[](#understanding-the-commands)

**Q: What's the difference between `php artisan git:sync` and `composer sync`?**

A: They do the exact same thing! `composer sync` is just a shortcut that internally calls `php artisan git:sync`.

- `php artisan git:sync` - Available immediately after `composer require`
- `composer sync` - Only available after running `php artisan git:sync:install` (one-time setup)

**Q: Do I need to run `git:sync:install`?**

A: No, it's completely optional! Use it only if you prefer typing `composer sync` instead of `php artisan git:sync`.

**Q: What does `git:sync:install` do?**

A: It adds this line to your project's `composer.json`:

```
"scripts": {
    "sync": "@php artisan git:sync"
}
```

This creates a Composer script alias, nothing more.

### Command Options Reference

[](#command-options-reference)

All commands support the same options:

OptionShorthandDescription`--message="text"``-m "text"`Custom commit message`--commit-only`-Commit without pushing`--push-only`-Push without committing`--pull`-Pull changes from remote before pushing`--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 --pull
git-sync --dry-run
git-sync --verbose
git-sync --branch=develop
```

**Examples with artisan (Per-Project):**

```
php artisan git:sync -m "Add new feature"
php artisan git:sync --commit-only
php artisan git:sync --pull
php artisan git:sync --dry-run
php artisan git:sync --branch=develop
```

**Examples with vendor/bin (Per-Project):**

```
vendor/bin/git-sync -m "Add new feature"
vendor/bin/git-sync --pull
vendor/bin/git-sync --verbose
```

Configuration
-------------

[](#configuration)

After 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'],
    ],
];
```

### Environment Variables

[](#environment-variables)

You can also configure via `.env`:

```
GIT_SYNC_COMMIT_PREFIX=feat
GIT_SYNC_TIMESTAMP_FORMAT="Y-m-d H:i:s"
GIT_SYNC_REMOTE=origin
```

Examples
--------

[](#examples)

### Daily Development Workflow

[](#daily-development-workflow)

**With 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-only
```

**With Per-Project Installation:**

```
# Quick save
php artisan git:sync

# With message
php artisan git:sync -m "Implement user authentication"

# Or use direct binary
vendor/bin/git-sync -m "Implement user authentication"
```

### Working with Feature Branches

[](#working-with-feature-branches)

**Global:**

```
git-sync -m "Add feature X"
git-sync --branch=feature/new-ui -m "Update UI components"
```

**Per-Project:**

```
php artisan git:sync -m "Add feature X"
php artisan git:sync --branch=feature/new-ui -m "Update UI components"
```

### Using in Non-Laravel Projects

[](#using-in-non-laravel-projects)

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.

Handling Remote Changes
-----------------------

[](#handling-remote-changes)

When the remote repository has commits that you don't have locally, you need to pull those changes before pushing. The `--pull` option handles this automatically:

**Global:**

```
# Pull and then push in one command
git-sync --pull -m "Update feature"

# With verbose output to see what's happening
git-sync --pull --verbose
```

**Per-Project:**

```
php artisan git:sync --pull -m "Update feature"
vendor/bin/git-sync --pull -m "Update feature"
```

The pull respects your git configuration. If you have `pull.rebase=true` set, it will rebase your commits. Otherwise, it will merge.

**Note:** If there are merge conflicts during the pull, the command will stop and prompt you to resolve them manually.

Error Handling
--------------

[](#error-handling)

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 (or use `--pull` option)
- **Merge conflicts**: Stops and prompts to resolve manually
- **No changes to commit**: Informs you the working tree is clean

Troubleshooting
---------------

[](#troubleshooting)

### "command not found: git-sync" (Global Installation)

[](#command-not-found-git-sync-global-installation)

If you get this error after global installation, Composer's bin directory is not in your PATH.

**Solution:**

1. Find your Composer bin directory:

    ```
    composer global config bin-dir --absolute
    ```
2. Add it to your PATH (choose based on your shell):

    **For Bash:**

    ```
    echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
    ```

    **For Zsh:**

    ```
    echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    ```
3. Verify it works:

    ```
    which git-sync
    git-sync --help
    ```

### "Command sync is not defined" (Per-Project Installation)

[](#command-sync-is-not-defined-per-project-installation)

The `composer sync` command doesn't work automatically after installing the package. It requires a one-time setup.

**Solution:**

Run the install command to enable `composer sync`:

```
php artisan git:sync:install
```

This automatically adds the `sync` script to your `composer.json`.

**Alternative:** Use these commands without setup:

```
php artisan git:sync
# or
vendor/bin/git-sync
```

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x
- Git installed on your system

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Credits
-------

[](#credits)

Created by [Aaron Idikko](https://github.com/aaronidikko)

Support
-------

[](#support)

If you find this package helpful, please consider:

- Starring the repository on GitHub
- Sharing it with others
- Reporting issues or suggesting features

Changelog
---------

[](#changelog)

### Version 1.2.0

[](#version-120)

- Added `--pull` option to pull remote changes before pushing
- Prevents commit history issues when remote has new commits
- Works with both rebase and merge strategies
- Handles merge conflicts gracefully
- Available in all command modes (artisan, composer, global)
- Added `php artisan git:sync:install` command for one-time composer sync setup
- Automatically adds `composer sync` script to project's composer.json
- Added comprehensive PATH setup instructions for global installation
- Added troubleshooting section for common installation issues
- Clarified usage commands for per-project vs global installation

### Version 1.0.0

[](#version-100)

- Initial release
- Basic git sync functionality
- Custom and auto-generated commit messages
- Multiple workflow modes
- Comprehensive error handling
- Configuration options
- Test suite

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance73

Regular maintenance activity

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

194d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/025abfaf3f70bddae774313eefaf7aaac252db7e2c5b0375703c0eb558870f3d?d=identicon)[aarondio](/maintainers/aarondio)

---

Top Contributors

[![Aarondio](https://avatars.githubusercontent.com/u/31071454?v=4)](https://github.com/Aarondio "Aarondio (34 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (2 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aaronidikko-laravel-git-sync/health.svg)

```
[![Health](https://phpackages.com/badges/aaronidikko-laravel-git-sync/health.svg)](https://phpackages.com/packages/aaronidikko-laravel-git-sync)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
