Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get git branch with php

function get_current_git_branch(){
    $fname = sprintf( '.git/HEAD' );
    $data = file_get_contents($fname);   
    $ar  = explode( "/", $data );
    $ar = array_reverse($ar);
    return  trim ("" . @$ar[0]) ;
}

function get_current_git_datetime( $branch='master' ) {
      $fname = sprintf( '.git/refs/heads/%s', $branch );
      $time = filemtime($fname);
      if($time != 0 ){
          return date("Y-m-d H:i:s", $time);
        }else{
            return  "time=0";
      }
}
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #git #branch #php
ADD COMMENT
Topic
Name
1+4 =