1/**
2 * @filename: currentgitbranch.php
3 * @usage: Include this file after the '<body>' tag in your project
4 * @author Kevin Ridgway
5 */
6 $stringfromfile = file('.git/HEAD', FILE_USE_INCLUDE_PATH);
7
8 $firstLine = $stringfromfile[0]; //get the string from the array
9
10 $explodedstring = explode("/", $firstLine, 3); //seperate out by the "/" in the string
11
12 $branchname = $explodedstring[2]; //get the one that is always the branch name
13
14 echo "<div style='clear: both; width: 100%; font-size: 14px; font-family: Helvetica; color: #30121d; background: #bcbf77; padding: 20px; text-align: center;'>Current branch: <span style='color:#fff; font-weight: bold; text-transform: uppercase;'>" . $branchname . "</span></div>"; //show it on the page
15