Trying to grab git info about a WordPress theme from within a plugin

Solution:

As shown in this build script, you need to make sure you are in the right folder:

//Time to set the Build Date and Revision.
$date = date( 'Y-m-d' );
$revision = '';
if ( file_exists( dirname( __FILE__ ) . '/.git/HEAD' ) ) {
    $revision = trim( exec( 'git rev-parse --short HEAD' ) );
    $out_contents = preg_replace( '#\$wpqi_version = \'([^\']+)\';#', '$wpqi_version = \'$1-' . $revision . '\';', $out_contents );
}
$out_contents = str_replace( '/*BuildDate*/', $date, $out_contents );