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

ActiveLibrary

konekt/git-php
==============

Easy to use GIT wrapper for PHP.

2.2.0(1w ago)24.5kMITPHPPHP ^8.2CI passing

Since Jan 22Pushed 1w agoCompare

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

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

Run Git Commands from PHP
=========================

[](#run-git-commands-from-php)

[![Tests](https://camo.githubusercontent.com/7173cd3c4704654087318428dfe1d29129591e863ba20efcc06a54be133a5bcb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6172746b6f6e656b742f6769742d7068702f74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/artkonekt/git-php/actions?query=workflow%3Atests)[![Packagist Stable Version](https://camo.githubusercontent.com/d929c7db2b865875580b356afad890d8eec2e8423d189b85c574b80ac56ddf1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f6e656b742f6769742d7068702e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/konekt/git-php)[![Packagist downloads](https://camo.githubusercontent.com/9421e4075058c66ebea6d2056148b56a026c09fe4bb1f31b6112b49180a51362/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6f6e656b742f6769742d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/konekt/git-php)[![StyleCI](https://camo.githubusercontent.com/0d57c328c205f6863357263505d6b13a6afd8b1433f68fdb0dad855c16548da7/68747470733a2f2f7374796c6563692e696f2f7265706f732f3331313031343735312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/311014751)[![MIT Software License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

> This repository was forked from [bit3/git-php](https://github.com/bit3/git-php) at its version 1.5.0.

GIT Wrapper for PHP
-------------------

[](#git-wrapper-for-php)

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

### Examples

[](#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)

```
GitRepository::in('/path/to/git/target/directory')->init()->execute();
```

#### clone a git repository

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

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

```
$git = GitRepository::in('/path/to/repo');
$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

58

—

FairBetter than 98% of packages

Maintenance98

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

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

Recently: every ~361 days

Total

14

Last Release

11d ago

Major Versions

1.5.0 → 2.0.02022-05-22

1.5.1 → 2.1.02023-05-27

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

1.5.0PHP ^5.6 || ^7.0

2.0.0PHP ^7.4 || ^8.0

2.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c398dd02c93ecf6aa344f367f5744aeb32b4c7bbc23b1b22e95336f45bf0d5a?d=identicon)[konekt](/maintainers/konekt)

---

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)")[![fulopattila122](https://avatars.githubusercontent.com/u/1162360?v=4)](https://github.com/fulopattila122 "fulopattila122 (26 commits)")[![baumannsven](https://avatars.githubusercontent.com/u/2493263?v=4)](https://github.com/baumannsven "baumannsven (14 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)")

---

Tags

gitphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.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.

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

PHPackages © 2026

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