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

ActiveLibrary

rodziu/php-git
==============

Pure PHP Git client (read only).

2.1.2(1y ago)311[1 PRs](https://github.com/Rodziu/php-git/pulls)MITPHPPHP &gt;=8.2

Since Feb 7Pushed 1y ago2 watchersCompare

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

READMEChangelogDependencies (4)Versions (10)Used By (0)

Pure PHP Git readonly client
============================

[](#pure-php-git-readonly-client)

Readonly Git client implementation, that allows one to clone or read Git repository data without native Git client installed.

Prerequisites
-------------

[](#prerequisites)

- PHP &gt;= 8.2,
- ext-zlib - to properly decompress git objects.

Usage
-----

[](#usage)

You can interact with Git repository by instantiating `GitRepository` class.

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
```

### Get current HEAD

[](#get-current-head)

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
$head = $gitRepository->getHead();
$head->getCommitHash(); // commit hash that current head points to
$head->getBranch(); // current branch, null if head is detached
```

### Get list of available local or remote branches

[](#get-list-of-available-local-or-remote-branches)

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
$gitRepository->getBranches(); // returns an array of local branch names
$gitRepository->getBranches(remote: true); // returns an array of remote branch names
```

### Get list of available tags

[](#get-list-of-available-tags)

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
foreach ($gitRepository->getTags() as $tag) {
    $tag; // \Rodziu\Git\Objects\Tag or \Rodziu\Git\Objects\AnnotatedTag
    $tag->getName();
    $tag->getTaggedObjectHash();
    ...
}
```

### Iterate git log starting from given commit-ish

[](#iterate-git-log-starting-from-given-commit-ish)

`GitRepository->getLog(?string $commitIsh = null): \Generator`

If argument is omitted, log will start from current HEAD.

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
foreach ($gitRepository->getLog() as $commit) {
    $commit; // \Rodziu\Git\Objects\Commit object
    $commit->getMessage();
    $commit->getCommitDate();
    ...
}

// get origin/master branch log
$gitRepository->getLog('origin/master');
```

### Get commit object by hash

[](#get-commit-object-by-hash)

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
$gitRepository->getCommit('commit-hash'); // \Rodziu\Git\Objects\Commit object
...
```

### git describe

[](#git-describe)

Give an object a human readable name based on an available ref

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
$gitRepository->describe(); // describe current HEAD with annotated tags
$gitRepository->describe('commit-ish', all: true); // describe given ref as in git describe --all
$gitRepository->describe('commit-ish', tags: true); // describe given ref as in git describe --tags
```

### git clone

[](#git-clone)

Fetch repository info and all objects up to current HEAD, then checkout its working tree to `/destination/path/repository-name`.

```
\Rodziu\Git\GitRepository::cloneRepository(
    'https://your.repository.url/repository-name.git',
    '/destination/path/'
);
```

### git fetch

[](#git-fetch)

Update repository data from remote

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
$gitRepository->fetch('origin');
```

### git checkout

[](#git-checkout)

Checkout working tree to given branch, tag or commit

```
$gitRepository = new \Rodziu\Git\GitRepository('/path/to/your/project/.git');
$gitRepository->checkout('commit-ish');
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity79

Established project with proven stability

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

Recently: every ~30 days

Total

7

Last Release

725d ago

Major Versions

1.1.0 → 2.0.02024-04-16

PHP version history (3 changes)1.0.0PHP &gt;7.2

1.1.0PHP ^7.2

2.0.0PHP &gt;=8.2

### Community

Maintainers

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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