📅  最后修改于: 2022-03-11 14:54:49.633000             🧑  作者: Mango
/**
* @filename: currentgitbranch.php
* @usage: Include this file after the '' tag in your project
* @author Kevin Ridgway
*/
$stringfromfile = file('.git/HEAD', FILE_USE_INCLUDE_PATH);
$firstLine = $stringfromfile[0]; //get the string from the array
$explodedstring = explode("/", $firstLine, 3); //seperate out by the "/" in the string
$branchname = $explodedstring[2]; //get the one that is always the branch name
echo "Current branch: " . $branchname . ""; //show it on the page