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

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

sebastianfeldmann/git
=====================

PHP git wrapper

3.16.0(4mo ago)487.4M↓12.6%13[2 issues](https://github.com/sebastianfeldmann/git/issues)15MITPHPPHP &gt;=8.0CI passing

Since Jan 23Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/sebastianfeldmann/git)[ Packagist](https://packagist.org/packages/sebastianfeldmann/git)[ Docs](https://github.com/sebastianfeldmann/git)[ GitHub Sponsors](https://github.com/sebastianfeldmann)[ RSS](/packages/sebastianfeldmann-git/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (2)Versions (67)Used By (15)

git - a handy git wrapper
=========================

[](#git---a-handy-git-wrapper)

[![Latest Stable Version](https://camo.githubusercontent.com/b190a96acfcff705d18dc6013288bdafdfbaba1de1f34a908479614668fef408/68747470733a2f2f706f7365722e707567782e6f72672f73656261737469616e66656c646d616e6e2f6769742f762f737461626c652e737667)](https://packagist.org/packages/sebastianfeldmann/git)[![Minimum PHP Version](https://camo.githubusercontent.com/4c62148864d567c4ee794ffab09c1dd4a3f45e41064bbb016440beddaae71a4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e322d3838393242462e737667)](https://php.net/)[![Downloads](https://camo.githubusercontent.com/1fc61f4d9adaa8986265a0c1dc5f63bafaec489a7a3c5111348742d58ec54bde/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656261737469616e66656c646d616e6e2f6769742e7376673f7631)](https://packagist.org/packages/sebastianfeldmann/git)[![License](https://camo.githubusercontent.com/dd0ab3beb8a0610ba9b46588a70136330a3c0c4bee5463a65c5740a84a6cd5c2/68747470733a2f2f706f7365722e707567782e6f72672f73656261737469616e66656c646d616e6e2f6769742f6c6963656e73652e737667)](https://packagist.org/packages/sebastianfeldmann/git)[![Build Status](https://github.com/sebastianfeldmann/git/workflows/CI-Build/badge.svg)](https://github.com/sebastianfeldmann/git/actions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7e1e6ae491ca9ac3495f727cf3c764758143364e1048d87c36a4b9ed8812d950/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73656261737469616e66656c646d616e6e2f6769742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sebastianfeldmann/git/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/60f1b4985ba7829cb31ee49152d21e019df06cded42aa1601eb519e5f4742034/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73656261737469616e66656c646d616e6e2f6769742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sebastianfeldmann/git/?branch=master)

This lib is used to execute `git` commands directly from PHP via a defined api. All you have to do is setup a `Repository` object, retrieve a command `Operator`and fire away. Each git command like git *config* or git *log* is handled by a separate `Operator`. Follow the next steps to give it a try.

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

[](#installation)

The git package is installable via composer. Just run the following command.

```
$ composer require sebastianfeldmann/git
```

Usage
-----

[](#usage)

Setup the `Repository`

```
$repoRootPath  = '/var/www/my-project';
$gitRepository = new Git\Repository($repoRootPath);
```

Retrieve the needed `Operator`

```
$log = $gitRepository->getLogOperator();
```

Get files and commits since some tag

```
$files   = $log->getChangedFilesSince('1.0.0');
$commits = $log->getCommitsSince('1.0.0');
```

Copy Paste Example
------------------

[](#copy-paste-example)

```
use SebastianFeldmann\Git;

require __DIR__ . '/../vendor/autoload.php';

// path to repository without .git
$repoRootPath  = '/path/to/repo';
$gitRepository = new Git\Repository($repoRootPath);

// get files and commits since hash or tag
$log     = $gitRepository->getLogOperator();
$files   = $log->getChangedFilesSince('1.0.0');
$commits = $log->getCommitsSince('1.0.0');

// check the index status
$index = $gitRepository->getIndexOperator();
$files = $index->getStagedFiles();
```

Available operators
-------------------

[](#available-operators)

- Config - Access all git settings e.g. line break settings.
- Diff - Compare two versions.
- Index - Check the staging area.
- Info - Access the current state like branch name or commit hash.
- Log - Returns list of changed files and other git log information.

Example commands
----------------

[](#example-commands)

Get the current tag:

```
// git describe --tag
$tag = $infoOperator->getCurrentTag();

```

Get tags for a given commit:

```
// git tag --points-at HEAD
$tags = $infoOperator->getTagsPointingTo('HEAD');

```

Get the current branch:

```
// git rev-parse --abbrev-ref HEAD
$branch = $infoOperator->getCurrentBranch();

```

Get a list of staged files:

```
// git diff-index --cached --name-status HEAD
$files = $indexOperator->getStagedFiles();

```

Get all current git settings:

```
// git config --list
$config = $configOperator->getSettings();

```

Get all changed files since a given commit or tag:

```
// git log --format='' --name-only $HASH
$files = $logOperator->changedFilesSince('1.0.0');

```

Get differences between two versions

```
// git diff '1.0.0' '1.1.0'
$changes = $diffOperator->compare('1.0.0', '1.1.0');

```

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance74

Regular maintenance activity

Popularity58

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.6% 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 ~51 days

Recently: every ~36 days

Total

65

Last Release

134d ago

Major Versions

1.2.1 → 2.0.02019-01-04

2.4.0 → 3.0.02019-12-06

PHP version history (6 changes)1.0.5PHP &gt;=7.0.0

2.0.0PHP &gt;=7.1

2.2.1PHP ^7.1

3.3.0PHP ^7.2

3.4.1PHP &gt;=7.2

3.10.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9250358?v=4)[Sebastian Feldmann](/maintainers/sebastianfeldmann)[@sebastianfeldmann](https://github.com/sebastianfeldmann)

---

Top Contributors

[![sebastianfeldmann](https://avatars.githubusercontent.com/u/9250358?v=4)](https://github.com/sebastianfeldmann "sebastianfeldmann (233 commits)")[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (12 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (4 commits)")[![piranos](https://avatars.githubusercontent.com/u/5470341?v=4)](https://github.com/piranos "piranos (4 commits)")[![PurpleBooth](https://avatars.githubusercontent.com/u/133327?v=4)](https://github.com/PurpleBooth "PurpleBooth (3 commits)")[![Technicky24](https://avatars.githubusercontent.com/u/169775297?v=4)](https://github.com/Technicky24 "Technicky24 (2 commits)")[![shochdoerfer](https://avatars.githubusercontent.com/u/596449?v=4)](https://github.com/shochdoerfer "shochdoerfer (2 commits)")[![pkruithof](https://avatars.githubusercontent.com/u/330828?v=4)](https://github.com/pkruithof "pkruithof (1 commits)")[![ktomk](https://avatars.githubusercontent.com/u/352517?v=4)](https://github.com/ktomk "ktomk (1 commits)")[![e2-robert](https://avatars.githubusercontent.com/u/58330729?v=4)](https://github.com/e2-robert "e2-robert (1 commits)")[![chapeupreto](https://avatars.githubusercontent.com/u/834048?v=4)](https://github.com/chapeupreto "chapeupreto (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![mdio](https://avatars.githubusercontent.com/u/8616698?v=4)](https://github.com/mdio "mdio (1 commits)")

---

Tags

gitgit-wrapperhacktoberfestphpgit

### Embed Badge

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

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

###  Alternatives

[czproject/git-php

Library for work with Git repository in PHP.

5645.1M101](/packages/czproject-git-php)[cypresslab/gitelephant

An abstraction layer for git written in PHP

6181.1M27](/packages/cypresslab-gitelephant)[teqneers/php-stream-wrapper-for-git

Git Stream Wrapper for PHP

2862.2M8](/packages/teqneers-php-stream-wrapper-for-git)[bruli/php-git-hooks

Git hooks for PHP projects.

674371.6k5](/packages/bruli-php-git-hooks)[marcocesarato/php-conventional-changelog

Generate changelogs and release notes from a project's commit messages and metadata and automate versioning with semver.org and conventionalcommits.org

2521.4M117](/packages/marcocesarato-php-conventional-changelog)[ramsey/conventional-commits

A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook action!

1931.5M142](/packages/ramsey-conventional-commits)

PHPackages © 2026

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