PHPackages                             bit3/git-php - 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. bit3/git-php

ActiveLibrary

bit3/git-php
============

Easy to use GIT wrapper for PHP.

1.5.1(3y ago)47143.4k↓29.7%24[2 issues](https://github.com/bit3/git-php/issues)[1 PRs](https://github.com/bit3/git-php/pulls)6MITPHPPHP ^5.6 || ^7.0CI failing

Since Jan 22Pushed 2y ago4 watchersCompare

[ Source](https://github.com/bit3/git-php)[ Packagist](https://packagist.org/packages/bit3/git-php)[ RSS](/packages/bit3-git-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (13)Used By (6)

[![Build Status](https://github.com/bit3/git-php/actions/workflows/diagnostics.yml/badge.svg)](https://github.com/bit3/git-php/actions)[![Latest Version tagged](https://camo.githubusercontent.com/459a7ad84df18727e92276dc6092937a5e9ff417189eccb8c40a066f59900919/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f626974332f6769742d7068702e737667)](https://github.com/bit3/git-php/tags)[![Latest Version on Packagist](https://camo.githubusercontent.com/d3b19206ae04a2fa85bcd51ab5a535ca54e411926c91423f8de792910b01187e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626974332f6769742d7068702e737667)](https://packagist.org/packages/bit3/git-php)[![Installations via composer per month](https://camo.githubusercontent.com/bd34f033e47d85184f9a06d791a3c32013a751855ced97c3f67e3ac6011e093d/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f626974332f6769742d7068702e737667)](https://packagist.org/packages/bit3/git-php)

Easy to use GIT wrapper for php
===============================

[](#easy-to-use-git-wrapper-for-php)

This is a lightweight wrapper, providing the git commands in PHP.

Usage examples
--------------

[](#usage-examples)

The API use command builders, that allow you to build a command and execute it one time.

The main synopsis is:

```
$git->command()->option()->execute();
```

`$git->command()` will create a new command, `*->option()` will add an option to the command and `*->execute()` will finally execute the command.

The naming of commands and options follow the git naming. If you search for documentation of a specific command or option, just look into the git documentation. You will find the command/option there.

#### init a new git repository

[](#init-a-new-git-repository)

```
use Bit3\GitPhp\GitRepository;

$directory = '/path/to/git/target/directory';

$git = new GitRepository($directory);
$git->init()->execute();
```

#### clone a git repository

[](#clone-a-git-repository)

The `clone` command is named `cloneRepository()` because `clone` is a reserved word in PHP.

```
use Bit3\GitPhp\GitRepository;

$directory = '/path/to/git/target/directory';

$git = new GitRepository($directory);
$git->cloneRepository()->execute();
```

#### describe

[](#describe)

```
$annotatedTag   = $git->describe()->execute();
$lightweightTag = $git->describe()->tags()->execute();
$recentRef      = $git->describe()->all()->execute();
```

#### set remote fetch url

[](#set-remote-fetch-url)

```
$git->remote()
    ->setUrl('origin', 'git@github.com:bit3/git-php.git')
    ->execute();
```

#### set remote push url

[](#set-remote-push-url)

```
$git->remote()
    ->setPushUrl('origin', 'git@github.com:bit3/git-php.git')
    ->execute();
```

#### add new remote

[](#add-new-remote)

```
$git->remote()
    ->add('github', 'git@github.com:bit3/git-php.git')
    ->execute();
```

#### fetch remote objects

[](#fetch-remote-objects)

```
$git->fetch()->execute('github');
```

#### checkout

[](#checkout)

```
$git->checkout()->execute('hotfix/1.2.3');
```

#### checkout specific path

[](#checkout-specific-path)

```
$git->checkout()->execute('hotfix/1.2.3', '/fileA', '/fileB', '/dir/fileC');
```

#### push objects

[](#push-objects)

```
$git->push()->execute('github', 'hotfix/1.2.3');
```

#### add file to staging index

[](#add-file-to-staging-index)

```
$git->add()->execute('file/to/add.ext');
```

#### remove file

[](#remove-file)

```
$git->rm()->execute('file/to/remove.ext');
```

#### commit changes

[](#commit-changes)

```
$git->commit()->message('Commit message')->execute();
```

#### create a tag

[](#create-a-tag)

```
$git->tag()->execute('v1.2.3');
```

### Convenience and shortcut methods

[](#convenience-and-shortcut-methods)

#### list remotes

[](#list-remotes)

```
$remotes = $git->remote()->getNames();

// array(
//     'origin',
//     'composer',
// )
```

#### list branches

[](#list-branches)

```
$remotes = $git->branch()->getNames();

// array(
//     'master',
//     'hotfix/1.2.3',
// )
```

#### list remote tracking branches

[](#list-remote-tracking-branches)

```
$remotes = $git->branch()->remotes()->->getNames();

// array(
//     'origin/master',
//     'origin/hotfix/1.2.3',
//     'origin/release/4.5.6',
// )
```

#### list branches including remote tracking branches

[](#list-branches-including-remote-tracking-branches)

```
$remotes = $git->branch()->all()->->getNames();

// array(
//     'master',
//     'hotfix/1.2.3',
//     'remotes/origin/master',
//     'remotes/origin/hotfix/1.2.3',
//     'remotes/origin/release/4.5.6',
// )
```

#### get modification status

[](#get-modification-status)

```
$status = $git->status()->getStatus();

// array(
//     'existing-file.txt'      => array('index' => 'D',   'worktree' => false),
//     'removed-but-staged.txt' => array('index' => 'D',   'worktree' => 'A'),
//     'staged-file.txt'        => array('index' => false, 'worktree' => 'A'),
//     'unknown-file.txt'       => array('index' => '?',   'worktree' => '?'),
// )
```

#### get index modification status

[](#get-index-modification-status)

```
$status = $git->status()->getIndexStatus();

// array(
//     'existing-file.txt'      => 'D',
//     'removed-but-staged.txt' => 'D',
//     'staged-file.txt'        => false,
//     'unknown-file.txt'       => '?',
// )
```

#### get worktree modification status

[](#get-worktree-modification-status)

```
$status = $git->status()->getWorkTreeStatus();

// array(
//     'existing-file.txt'      => 'worktree' => false,
//     'removed-but-staged.txt' => 'worktree' => 'A',
//     'staged-file.txt'        => 'worktree' => 'A',
//     'unknown-file.txt'       => 'worktree' => '?',
// )
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~321 days

Recently: every ~591 days

Total

10

Last Release

1238d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3

1.5.0PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e61f74ea186c1e79e072b2974ccdeef39414730476d5a8adac501eb9449b2a3?d=identicon)[tril](/maintainers/tril)

![](https://avatars.githubusercontent.com/u/44649522?v=4)[xtra](/maintainers/xtra)[@xtra](https://github.com/xtra)

---

Top Contributors

[![tristanlins](https://avatars.githubusercontent.com/u/343404?v=4)](https://github.com/tristanlins "tristanlins (69 commits)")[![discordier](https://avatars.githubusercontent.com/u/940331?v=4)](https://github.com/discordier "discordier (42 commits)")[![baumannsven](https://avatars.githubusercontent.com/u/2493263?v=4)](https://github.com/baumannsven "baumannsven (30 commits)")[![Arkitecht](https://avatars.githubusercontent.com/u/66117?v=4)](https://github.com/Arkitecht "Arkitecht (3 commits)")[![dmolineus](https://avatars.githubusercontent.com/u/1186266?v=4)](https://github.com/dmolineus "dmolineus (2 commits)")[![djmattyg007](https://avatars.githubusercontent.com/u/489338?v=4)](https://github.com/djmattyg007 "djmattyg007 (1 commits)")[![ahmad-marzouq](https://avatars.githubusercontent.com/u/22179873?v=4)](https://github.com/ahmad-marzouq "ahmad-marzouq (1 commits)")[![IdrisDose](https://avatars.githubusercontent.com/u/2646100?v=4)](https://github.com/IdrisDose "IdrisDose (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bit3-git-php/health.svg)

```
[![Health](https://phpackages.com/badges/bit3-git-php/health.svg)](https://phpackages.com/packages/bit3-git-php)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)

PHPackages © 2026

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