PHPackages                             cytopia/check\_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. cytopia/check\_git

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

cytopia/check\_git
==================

Nagios plugin to verify a git repository.

0.6(9y ago)105.2k7[2 PRs](https://github.com/cytopia/check_git/pulls)MITShell

Since Dec 5Pushed 3y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (6)Used By (0)

check\_git
==========

[](#check_git)

Nagios plugin to verify a git directory. Checks include `git status` (with or without submodules), HEAD is on a branch or tag (any or specified), has diffs against remote (with or without submodules), HEAD (tag, branch or commit) is GPG signed and the signature is valid.

[![Build Status](https://camo.githubusercontent.com/c42e32988f7b14fd323300802d1f60e5a2320005a131025e58ffde10e60b8d3f/68747470733a2f2f7472617669732d63692e6f72672f6379746f7069612f636865636b5f6769742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cytopia/check_git)[![Latest Stable Version](https://camo.githubusercontent.com/b0a1e54d150b8624fbdfca272e65e4a88103fb4af25c057c9801e4308409351f/68747470733a2f2f706f7365722e707567782e6f72672f6379746f7069612f636865636b5f6769742f762f737461626c65)](https://packagist.org/packages/cytopia/check_git) [![Total Downloads](https://camo.githubusercontent.com/43c5b1c62d1b13d4557c5d9a2fd831767722748cacf99792b9bee64a7c247a0e/68747470733a2f2f706f7365722e707567782e6f72672f6379746f7069612f636865636b5f6769742f646f776e6c6f616473)](https://packagist.org/packages/cytopia/check_git) [![Latest Unstable Version](https://camo.githubusercontent.com/5fcbf4a105becb29f99ef83310b0d28539f0da48a56df23a7b05159f78853cdf/68747470733a2f2f706f7365722e707567782e6f72672f6379746f7069612f636865636b5f6769742f762f756e737461626c65)](https://packagist.org/packages/cytopia/check_git) [![License](https://camo.githubusercontent.com/0664be17b01a8e96fc22fa3c57e77ac258b18060c6cbf51054276ba98e5e0877/68747470733a2f2f706f7365722e707567782e6f72672f6379746f7069612f636865636b5f6769742f6c6963656e7365)](http://opensource.org/licenses/MIT)[![POSIX](https://camo.githubusercontent.com/feb63e4a980dfcca96f4cc1f5d5a8ed53ea3951e4db4bc39427267e5245978bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706f7369782d3130302532352d627269676874677265656e2e737667)](https://en.wikipedia.org/?title=POSIX)[![Type](https://camo.githubusercontent.com/466a2aaa559c1fa8990a00e9b3d30900ae8559d4f772913b12b1cd334e0ffeac/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747970652d25324662696e25324673682d7265642e737667)](https://en.wikipedia.org/?title=Bourne_shell)

---

[![Awesome-Nagios-Plugins](https://raw.githubusercontent.com/cytopia/awesome-nagios-plugins/master/doc/img/awesome-nagios.png)](https://github.com/cytopia/awesome-nagios-plugins)Find more plugins at [Awesome Nagios](https://github.com/cytopia/awesome-nagios-plugins)[![Icinga Exchange](https://raw.githubusercontent.com/cytopia/awesome-nagios-plugins/master/doc/img/icinga.png)](https://exchange.icinga.com/cytopia)**Find more plugins at [Icinga Exchange](https://exchange.icinga.com/cytopia)**[![Nagios Exchange](https://raw.githubusercontent.com/cytopia/awesome-nagios-plugins/master/doc/img/nagios.png)](https://exchange.nagios.org/directory/Owner/cytopia/1)**Find more plugins at [Nagios Exchange](https://exchange.nagios.org/directory/Owner/cytopia/1)**---

1. Nagios / Icinga integration
------------------------------

[](#1-nagios--icinga-integration)

There are two ways how to integrate this with nagios or icinga.

### 1.1 Direct approach (not recommended)

[](#11-direct-approach-not-recommended)

Use `check_git` directly from nagios and test a repository every time a check is triggered. In order for the output to be usaeble by Nagios / Icinga, you will have to use `-n `, which will amongst others remove the shell colors from the output. Correct exit codes for `success`, `warning`, `error` and `unknown` are thrown by default.

**Example**

```
$ check_git -d  -s -n
```

### 1.2 Approach to just parse a logfile (recommended)

[](#12-approach-to-just-parse-a-logfile-recommended)

This approach reduces the overhead to check a repository every 5min by nagios, and rather check the logfile created by `check_git`. Sometimes a full check (status, gpg, remote check, etc) can take up to a few seconds and u don't want to stress the system every 5min.

For that to work, you simply add `check_git` to your crontab and only check your repository every 4 hours for example. Nagios / Icinga can still check the logfile every 5 minutes.

**Crontab**

```
0 0,4,8,12,16,20 * * * /full/path/to/check_git -d  -n  -l /var/log/git/.log
```

This will update the logfile under `/var/log/git/.log` every 4 hours and nagios/icinga can however check on it as often as they want via:

**The actual check**

```
$ check_git_log -f /var/log/git/.log
```

2. Examples
-----------

[](#2-examples)

The following examples show each options separately, you can of course combine most checks.

### 2.1 Check git status

[](#21-check-git-status)

Without submodules (`-s`)

```
$ check_git -d /shared/httpd/my-project/ -s -n My-Project
[SUCCESS] My-Project git repo is healthy.
[SUCCESS]  Git status: clean
```

With submodules (`-S`)

```
$ check_git -d /shared/httpd/my-project/ -S -n My-Project
[CRITICAL] My-Project git repo has errors.
[SUCCESS]  Git status: clean
[CRITICAL] Git status: submodule(s) unclean
```

### 2.2 Check status of HEAD (branch or tag)

[](#22-check-status-of-head-branch-or-tag)

HEAD must be on a branch (any branch `-b`)

```
$ check_git -d /shared/httpd/my-project/ -b -n My-Project
[SUCCESS] My-Project git repo is healthy.
[SUCCESS]  Git Branch: on branch 'develop'
```

HEAD must be on branch *develop* (`-B`)

```
$ check_git -d /shared/httpd/my-project/ -B develop -n My-Project
[SUCCESS] My-Project git repo is healthy.
[SUCCESS]  Git Branch: on branch 'develop'
```

HEAD must be on a tag (any tag `-t`)

```
$ check_git -d /shared/httpd/my-project/ -t -n My-Project
[CRITICAL] My-Project git repo has errors.
[CRITICAL] Git Tag:    not on any tag
```

HEAD must be on tag 0.3 (`-T`)

```
$ check_git -d /shared/httpd/my-project/ -T 0.3 -n My-Project
[CRITICAL] My-Project git repo has errors.
[CRITICAL] Git Tag:    on tag '0.2', but should be on: '0.3'
```

### 2.3 Check GPG signature of commit/tag

[](#23-check-gpg-signature-of-committag)

Check if the current commit (or if HEAD is a tag, the current tag) is signed with gpg and valid (`-g`).

```
$ check_git -d /shared/httpd/my-project/ -g -n My-Project
[SUCCESS] My-Project git repo is healthy.
[SUCCESS]  GPG Signed: Yes with key: 695128A2
[SUCCESS]  GPG Pubkey: available
[SUCCESS]  GPG Signer: cytopia
[SUCCESS]  GPG Trust:  ULTIMATE
```

Check if the current commit (or if HEAD is a tag, the current tag) is signed with gpg, valid and matches one of the specified key ids (`-G`).

```
$ check_git -d /shared/httpd/my-project/ -G 695128A2,00000000,11111111,22222222 -n My-Project
[SUCCESS] My-Project git repo is healthy.
[SUCCESS]  GPG Signed: Yes with expected key: 695128A2
[SUCCESS]  GPG Pubkey: available
[SUCCESS]  GPG Signer: cytopia
[SUCCESS]  GPG Trust:  ULTIMATE
```

### 2.4 Check Diff against remote

[](#24-check-diff-against-remote)

Check if you have new code to pull (only makes sense if you are on a branch). Check excluding submodules (`-R`)

```
$ check_git -d /shared/httpd/my-project/ -R origin -n My-Project
[SUCCESS] My-Project git repo is healthy.
[SUCCESS]  Git remote: equals with 'origin'
```

Check if you have new code to pull (only makes sense if you are on a branch). Check including submodules (`-r`)

```
$ check_git -d /shared/httpd/my-project/ -r origin -n My-Project
[CRITICAL] My-Project git repo has errors.
[SUCCESS]  Git remote: equals with 'origin'
[CRITICAL] Git remote: submodule(s) differs from 'origin'
```

### 2.5 Show additional verbose output

[](#25-show-additional-verbose-output)

Show some verbose output (will also be visible within nagios extended output)

```
$ check_git -d /shared/httpd/my-project/ -v -n My-Project
[SUCCESS] My-Project git repo is healthy.
[INFO]     Bin:        git version 2.10.2
[INFO]     Path:       /shared/httpd/my-project/
[INFO]     Submodules: 2
[INFO]     HEAD:       on branch 'develop'
[INFO]     GPG:        signed 695128A2
```

3. Usage
--------

[](#3-usage)

```
Usage: check_git -d  [-s|-S] [-r|-R ] [-b] [-B ] [-t] [-T ]] [-g] [-G [,]] [-v]
OR               -d  [-n ] [-l logfile] [-s|-S] [-r|-R ] [-b] [-B ] [-t] [-T ]] [-g] [-G [,]] [-v]
OR               -h
OR               -V

check_git can validate a git repository by different requirements
You can have normal output or nagios (-n) compatible output to
integrate this into your monitoring system.

 Required arguments:

   -d        Specify path to git repository.

 Optional arguments (output):

   -v                 Be more verbose.

   -n           Create nagios style check outout.
                      Removes colors and adds a project name to the first line.

   -l        Log to file instead of stdout.
                      This is especially useful if you want to integrate this check via nagios.
                      You can then add a cronjob which periodically logs to file (as your deploy user)
                      and the nagios check simply parses the logfile via 'check_git_log'.
                      Requires '-n'.

 Optional arguments (checks):

   -s                 Check if git directory is clean.
                      This also take any submodules into account.
                      To prevent checking submodules use '-S'.
                      '-s' and '-S' are mutually exclusive.

   -S                 Check if git directory is clean (ignore submodules).
                      This ignores any submodules.
                      To also check against submodules use '-s'.
                      '-s' and '-S' are mutually exclusive.

   -r         Check if git repository is in sync with remote.
                      This option makes only sense, if your repository is
                      checked out on a branch that can be compared with remote.
                      This also take any submodules into account.
                      To prevent checking submodules use '-R'.
                      '-r' and '-R' are mutually exclusive.

   -R         Check if git repository is in sync with remote (ignore submodules).
                      This option makes only sense, if your repository is
                      checked out on a branch that can be compared with remote.
                      This ignores any submodules.
                      To also check submodules use '-r'.
                      '-r' and '-R' are mutually exclusive.
   -b                 Check if repository is checkout out on a branch.
                      No detached HEAD or tag.
                      '-b', '-B', '-t' and '-T' are mutually exclusive.

   -B []      Check if repository is checkout out on the specified branch.
                      '-b', '-B', '-t' and '-T' are mutually exclusive.

   -t                 Check if repository is checkout out on a tag.
                      No detached HEAD or branch.
                      '-b', '-B', '-t' and '-T' are mutually exclusive.

   -T []         Check if repository is checkout out on the specified tag.
                      No detached HEAD or branch.
                      '-b', '-B', '-t' and '-T' are mutually exclusive.

   -g                 Check if current HEAD is signed and has a valid GPG signature.
                      If current HEAD is a tag, the GPG signature of the tag is checked,
                      instead of the signature of the current commit.
                      For this to pass, you will also have to add your trusted
                      GPG public keys locally.
                      Returns:
                          Error, if not signed.
                          Warning, if signed, but pubkey is not available.
                          Warning, if signed, but pubkey is not trusted.
                          OK, if signed, pubkey is available and trusted.
                      '-g', and '-G' are mutually exclusive.

   -G [,] Check if current HEAD is signed by the given key id (hash) and has a valid GPG signature.
                      You can separate multiple key-id's via comma without space.
                      key-id (hash) must be the last 8 characters (all uppercase) of the key.
                      If current HEAD is a tag, the GPG signature of the tag is checked,
                      instead of the signature of the current commit.
                      For this to pass, you will also have to add your trusted
                      GPG public keys locally.
                      Returns:
                          Error, if not signed.
                          Error, if signed with a different key-id.
                          Warning, if signed, but pubkey is not available.
                          Warning, if signed, but pubkey is not trusted.
                          OK, if signed, pubkey is available and trusted.
                      '-g', and '-G' are mutually exclusive.

 Version and Help:

   -V                 Show version information
   -h                 Show this help screen
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

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

Every ~1 days

Total

5

Last Release

3436d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/527dbe351b75d33be6d5428502783ceb57e86949892a0a0062f24199772aabae?d=identicon)[cytopia](/maintainers/cytopia)

---

Top Contributors

[![cytopia](https://avatars.githubusercontent.com/u/12533999?v=4)](https://github.com/cytopia "cytopia (20 commits)")

---

Tags

gitnagiosicinganagios-plugin

### Embed Badge

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

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

###  Alternatives

[czproject/git-php

Library for work with Git repository in PHP.

5544.9M80](/packages/czproject-git-php)[cypresslab/gitelephant

An abstraction layer for git written in PHP

6131.0M23](/packages/cypresslab-gitelephant)[bruli/php-git-hooks

Git hooks for PHP projects.

675370.8k5](/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

2511.3M108](/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.2M121](/packages/ramsey-conventional-commits)[sebastianfeldmann/git

PHP git wrapper

466.9M18](/packages/sebastianfeldmann-git)

PHPackages © 2026

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