📌  相关文章
📜  使用 php 代码示例获取 git 分支

📅  最后修改于: 2022-03-11 14:53:42.595000             🧑  作者: Mango

代码示例1
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";
      }
}