Luke Oliff Luke Oliff - 1 year ago 114
PHP Question

i want to display the git version on my site

I want to display the git version number on my site.

I found that it was a commit hash and this wasn't suitable for non-technical users to reference.

I have created this class to display the version 'number' of the current git local to this script.

Answer Source



class QuickGit {

  public static function version() {
    exec('git describe --always',$version_mini_hash);
    exec('git rev-list HEAD | wc -l',$version_number);
    exec('git log -1',$line);
    $version['short'] = "v1.".trim($version_number[0]).".".$version_mini_hash[0];
    $version['full'] = "v1.".trim($version_number[0]).".$version_mini_hash[0] (".str_replace('commit ','',$line[0]).")";
    return $version;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download