Skip to content
A Laravel package that gives you information about the current git state.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Laravel Git State

Build Status Coverage Status Total Downloads Latest Stable Version License

A Laravel package that gives you information about the current git state.


You can install this package with composer:

composer require markwalet/laravel-git-state

Laravel >=5.5 uses Package auto-discovery, so you don't have to register the service provider. If you want to register the service provider manually, add the following line to your config/app.php file:



When you want to get information about the current git state, you can inject the \MarkWalet\GitState\Drivers\GitDriver class in your methods:


use MarkWalet\GitState\Drivers\GitDriver;

class Controller {
    public function index(GitDriver $driver) {
        $branch = $driver->currentBranch();
        return view('index', compact('branch'));

When injecting a GitDriver like this, you will get an instance of the default driver you configured. If you want to have more control over the driver you are using, you can use the MarkWalet\GitState\GitManager:


use MarkWalet\GitState\GitStateManager;

class Controller {
    public function index(GitStateManager $driver) {
        $branch = $driver->driver('other-driver')->currentBranch();
        return view('index', compact('branch'));


The default configuration is defined in git-state.php. If you want to edit this file you can copy it to your config folder by using the following command:

php artisan vendor:publish --provider="MarkWalet\GitState\GitServiceProvider"

In this file you can configure different drivers for fetching the current Git state, as well as setting a default configuration.

The supported drivers are: exec and file. There is also a fake implementation for testing purposes.

You can’t perform that action at this time.