PHPackages                             antogno/gitinfo - 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. antogno/gitinfo

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

antogno/gitinfo
===============

GitInfo is a tool that lets you get information about the current Git repository

v1.0.0(3y ago)018CC0-1.0PHPPHP &gt;=7.0.0

Since Mar 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/antogno/gitinfo)[ Packagist](https://packagist.org/packages/antogno/gitinfo)[ RSS](/packages/antogno-gitinfo/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

GitInfo
=======

[](#gitinfo)

 [![License](https://camo.githubusercontent.com/70ae17412e7a2b2d964a5fab9434be132901bb03f3109efdf3c44517990ea16e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616e746f676e6f2f676974696e666f)](https://github.com/antogno/gitinfo/blob/master/LICENSE) [![Last commit](https://camo.githubusercontent.com/cf235bf09310672af04f353da971f70fbe3b5e1e63b5e2e88aa76ae887ba51c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f616e746f676e6f2f676974696e666f)](https://github.com/antogno/gitinfo/commits) [![Last release](https://camo.githubusercontent.com/c99e38af4e6a032a5a30de3322d68802db49790275f634e2b6400410b1f569c7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f616e746f676e6f2f676974696e666f3f6c6162656c3d6c61737425323072656c65617365)](https://github.com/antogno/gitinfo/releases/latest)

GitInfo is a tool that lets you get information about the current Git repository.

---

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

[](#installation)

Use the dependency manager [Composer](https://getcomposer.org/download/) to install GitInfo.

```
$ composer require antogno/gitinfo
```

Usage
-----

[](#usage)

```
use antogno\GitInfo\GitInfo;

$GitInfo = new GitInfo();
```

Get the Git version:

```
$GitInfo->getGitVersion();
// For example: string(6) "2.40.0"
```

Get any deleted file:

```
$GitInfo->getDeletedFiles(false);
// For example: array(2) { [0]=> string(13) "deleted_1.php" [1]=> string(13) "deleted_2.php" }

$GitInfo->getDeletedFiles(true);
// For example: array(2) { [0]=> string(36) "/Users/antogno/gitinfo/deleted_1.php" [1]=> string(36) "/Users/antogno/gitinfo/deleted_2.php" }
```

Get any modified file:

```
$GitInfo->getModifiedFiles(false);
// For example: array(2) { [0]=> string(14) "modified_1.php" [1]=> string(14) "modified_2.php" }

$GitInfo->getModifiedFiles(true);
// For example: array(2) { [0]=> string(37) "/Users/antogno/gitinfo/modified_1.php" [1]=> string(37) "/Users/antogno/gitinfo/modified_2.php" }
```

Get any renamed file:

```
$GitInfo->getRenamedFiles(false);
// For example: array(1) { ["old_name.php"]=> string(12) "new_name.php" }

$GitInfo->getRenamedFiles(true);
// For example: array(1) { ["/Users/antogno/gitinfo/old_name.php"]=> string(35) "/Users/antogno/gitinfo/new_name.php" }
```

Get any unmerged file:

```
$GitInfo->getUnmergedFiles(false);
// For example: array(2) { [0]=> string(14) "unmerged_1.php" [1]=> string(14) "unmerged_2.php" }

$GitInfo->getUnmergedFiles(true);
// For example: array(2) { [0]=> string(37) "/Users/antogno/gitinfo/unmerged_1.php" [1]=> string(37) "/Users/antogno/gitinfo/unmerged_2.php" }
```

Get any untracked file:

```
$GitInfo->getUntrackedFiles(false);
// For example: array(2) { [0]=> string(15) "untracked_1.php" [1]=> string(15) "untracked_2.php" }

$GitInfo->getUntrackedFiles(true);
// For example: array(2) { [0]=> string(38) "/Users/antogno/gitinfo/untracked_1.php" [1]=> string(38) "/Users/antogno/gitinfo/untracked_2.php" }
```

Get any staged file:

```
$GitInfo->getStagedFiles(false);
// For example: array(2) { [0]=> string(12) "modified.php" [1]=> string(11) "deleted.php" }

$GitInfo->getStagedFiles(true);
// For example: array(2) { [0]=> string(35) "/Users/antogno/gitinfo/modified.php" [1]=> string(34) "/Users/antogno/gitinfo/deleted.php" }
```

Get any unstaged file:

```
$GitInfo->getUnstagedFiles(false);
// For example: array(2) { [0]=> string(12) "modified.php" [1]=> string(11) "deleted.php" }

$GitInfo->getUnstagedFiles(true);
// For example: array(2) { [0]=> string(35) "/Users/antogno/gitinfo/modified.php" [1]=> string(34) "/Users/antogno/gitinfo/deleted.php" }
```

### Author

[](#author)

Whether the given author exists or not:

```
$GitInfo->hasAuthor('tonio.granaldi@gmail.com', 'antogno');
// For example: bool(true)

$GitInfo->hasAuthor('', 'johndoe');
// For example: bool(false)

$GitInfo->hasAuthor('TONIO.GRANALDI@GMAIL.COM', 'ANTOGNO');
// For example: bool(true)
```

Get the author of the current commit:

```
$GitInfo->getCurrentCommitAuthor();
```

Get the given author, if exists:

```
$GitInfo->getAuthor('tonio.granaldi@gmail.com', 'antogno');

$GitInfo->getAuthor('', 'antogno');

$GitInfo->getAuthor('TONIO.GRANALDI@GMAIL.COM');
```

Get the authors list:

```
$GitInfo->getAuthors();
```

Each of the previous three methods returns an [`AuthorResource`](#authorresource) object (or a list of such).

#### `AuthorResource`

[](#authorresource)

```
use antogno\GitInfo\Resources\AuthorResource;

$Author = new AuthorResource('tonio.granaldi@gmail.com', 'antogno');

$Author = new AuthorResource('', 'antogno');

$Author = new AuthorResource('TONIO.GRANALDI@GMAIL.COM');
```

Get the author name:

```
$Author->getName();
// For example: string(7) "antogno"
```

Get the author email:

```
$Author->getEmail();
// For example: string(24) "tonio.granaldi@gmail.com"
```

Get the author commits ([`CommitResource`](#commitresource) list):

```
$Author->getCommits();
```

### Branch

[](#branch)

Whether the given branch exists or not:

```
$GitInfo->hasBranch('master');
// For example: bool(true)

$GitInfo->hasBranch('MASTER');
// For example: bool(false)
```

Get the current branch:

```
$GitInfo->getCurrentBranch();
```

Get the given branch, if exists:

```
$GitInfo->getBranch('master');
```

Get the branches list:

```
$GitInfo->getBranches();
```

Each of the previous three methods returns a [`BranchResource`](#branchresource) object (or a list of such).

#### `BranchResource`

[](#branchresource)

```
use antogno\GitInfo\Resources\BranchResource;

$Branch = new BranchResource('master');
```

Get the author name:

```
$Branch->getName();
// For example: string(6) "master"
```

Get the branch last commit ([`CommitResource`](#commitresource)):

```
$Branch->getLastCommit();
```

### Commit

[](#commit)

Whether a commit with the given hash exists or not:

```
$GitInfo->hasCommit('ed8f9325485f108ddafe3890dc4b13be07aa13cb');
// For example: bool(true)

$GitInfo->hasCommit('ed8f932');
// For example: bool(true)
```

Get the current commit:

```
$GitInfo->getCurrentCommit();
```

Get the given commit, if exists:

```
$GitInfo->getCommit('ed8f9325485f108ddafe3890dc4b13be07aa13cb');

$GitInfo->getCommit('ed8f932');
```

Get the commits list:

```
$GitInfo->getCommits();
```

Each of the previous three methods returns a [`CommitResource`](#commitresource) object (or a list of such).

#### `CommitResource`

[](#commitresource)

```
use antogno\GitInfo\Resources\CommitResource;

$Commit = new CommitResource('ed8f9325485f108ddafe3890dc4b13be07aa13cb');

$Commit = new CommitResource('ed8f932');
```

Get the long commit hash:

```
$Commit->getLongHash();
// For example: string(40) "ed8f9325485f108ddafe3890dc4b13be07aa13cb"
```

Get the short commit hash:

```
$Commit->getShortHash();
// For example: string(7) "ed8f932"
```

Get the commit message:

```
$Commit->getMessage();
// For example: string(14) "Initial commit"
```

Get the commit date (`DateTime`):

```
$Commit->getDate();
```

Get the commit author ([`AuthorResource`](#authorresource)):

```
$Commit->getAuthor();
```

### Tag

[](#tag)

Whether the given tag exists or not:

```
$GitInfo->hasTag('v1.0.0');
// For example: bool(true)

$GitInfo->hasTag('V1.0.0');
// For example: bool(false)
```

Get the current tag, if in a tag:

```
$GitInfo->getCurrentTag();
```

Get the given tag, if exists:

```
$GitInfo->getTag('v1.0.0');
```

Get the tags list:

```
$GitInfo->getTags();
```

Each of the previous three methods returns a [`TagResource`](#tagresource) object (or a list of such).

#### `TagResource`

[](#tagresource)

```
use antogno\GitInfo\Resources\TagResource;

$Tag = new TagResource('v1.0.0');
```

Get the tag name:

```
$Tag->getName();
// For example: string(6) "v1.0.0"
```

Get the tag last commit ([`CommitResource`](#commitresource)):

```
$Tag->getLastCommit();
```

### Remote

[](#remote)

Whether the given remote exists or not:

```
$GitInfo->hasRemote('origin');
// For example: bool(true)

$GitInfo->hasRemote('ORIGIN');
// For example: bool(false)
```

Get the remote from which the current branch is tracking:

```
$GitInfo->getCurrentRemote();
```

Get the given remote, if exists:

```
$GitInfo->getRemote('origin');
```

Get the remotes list:

```
$GitInfo->getRemotes();
```

Each of the previous three methods returns a [`RemoteResource`](#remoteresource) object (or a list of such).

#### `RemoteResource`

[](#remoteresource)

```
use antogno\GitInfo\Resources\RemoteResource;

$Remote = new RemoteResource('origin');
```

Get the remote name:

```
$Remote->getName();
// For example: string(6) "origin"
```

Get the remote URL:

```
$Remote->getUrl();
// For example: string(38) "https://github.com/antogno/gitinfo.git"
```

License
-------

[](#license)

GitInfo is licensed under the terms of the [Creative Commons Zero v1.0 Universal license](https://github.com/antogno/gitinfo/blob/master/LICENSE).

For more information, see the [Creative Commons website](https://creativecommons.org/publicdomain/zero/1.0/).

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/878dedc43e1b8950acc08e6776448d2163dd60db543ce42b4915bc064a9af130?d=identicon)[antogno](/maintainers/antogno)

---

Top Contributors

[![antogno](https://avatars.githubusercontent.com/u/84918191?v=4)](https://github.com/antogno "antogno (1 commits)")

---

Tags

composercomposer-packagegitpackagistphptooltoolgit

### Embed Badge

![Health badge](/badges/antogno-gitinfo/health.svg)

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

###  Alternatives

[phing/phing

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

1.2k22.5M912](/packages/phing-phing)[bamarni/composer-bin-plugin

No conflicts for your bin dependencies

53024.4M1.1k](/packages/bamarni-composer-bin-plugin)[czproject/git-php

Library for work with Git repository in PHP.

5645.2M112](/packages/czproject-git-php)[cypresslab/gitelephant

An abstraction layer for git written in PHP

6131.2M31](/packages/cypresslab-gitelephant)[teqneers/php-stream-wrapper-for-git

Git Stream Wrapper for PHP

2892.2M8](/packages/teqneers-php-stream-wrapper-for-git)[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.5M118](/packages/marcocesarato-php-conventional-changelog)

PHPackages © 2026

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