Skip to content

Instantly share code, notes, and snippets.

Created July 26, 2013 21:39
What would you like to do?
Parse current branch name from Git repository and conditionally set WordPress database name.
$git_head = file('.git/HEAD', FILE_USE_INCLUDE_PATH);
$git_head = $git_head[0]; //get the string from the array
$git_head = explode("/", $git_head); //separate out by the "/" in the string
$branch_name = trim($git_head[2]); //get the one that is always the branch name
if($branch_name == "master")
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress_local');
define('DB_NAME', 'wordpress_new');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment