Git branch in browser title in development

Public

Prepends the <head> title with the currently active git branch. I usually put this in my settings.local.php (more info: http://drupal.org/node/1118520)

UPDATE: The Environment Indicator module (https://www.drupal.org/project/environment_indicator) can now show the active branch in your administration toolbar, as of version 7.x-2.3.

Get raw version
php
  1. /**
  2.  * Implement hook_preprocess_HOOK() for node.
  3.  *
  4.  * We implement this hook for node because we need a module that hasn't already
  5.  * implemented it. If this ever becomes an issue, just change "node" to another
  6.  * module that doesn't implement this.
  7.  */
  8. function node_preprocess_html(&$variables) {
  9. /* Minimum git version 1.7.10 for this command to work */
  10. $branch = exec('git symbolic-ref --short HEAD');
  11. $variables['head_title'] = '[' . $branch . '.local] ' . $variables['head_title'];
  12. }