NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Git for Laravel

Branches & commits

Branches come back as a Page of branch names:

$branches = Git::github()->repo('acme/api')->branches()->items; // ['main', 'dev']

The commit query

commits() returns a chainable CommitQuery. Every filter is optional and URL-encoded for you:

$repo = Git::github()->repo('acme/api');

$commits = $repo->commits()               // CommitQuery
    ->branch('feature/new ui')            // properly URL-encoded
    ->author('jane-doe')
    ->path('src/')
    ->since(now()->subWeek())             // Carbon or an ISO 8601 string
    ->until(now())
    ->perPage(50)
    ->get();                              // Page<Commit>

$repo->commits()->get(page: 2);             // a specific page
$repo->commits()->collect();                // Collection<Commit>
$repo->commits()->branch('main')->first();  // ?Commit

foreach ($repo->commits()->branch('main')->lazy() as $commit) {
    // auto-paginated stream
}
  • branch(), author(), path() — narrow by ref, author and file path.
  • since() / until() — a Carbon instance or an ISO 8601 string.
  • perPage() — page size; get($page) — one Page<Commit>; collect($page) — that page as a Collection.
  • first() — the first matching commit or null; lazy() — a LazyCollection across every page.

GitHub and GitLab apply every filter. Bitbucket’s commits endpoint filters by branch() and path() only, so on Bitbucket author(), since() and until() throw FeatureNotSupportedException when the query runs, rather than returning unfiltered commits.

A single commit

$commit = Git::github()->repo('acme/api')->commit('6dcb09b...');

$commit->sha;
$commit->message;
$commit->author->name;   // Author: name, email, avatar
$commit->author->email;
$commit->url;            // ?string
$commit->commitAt;       // Carbon

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.