---
title: "Tip: Show the last git commit in the site footer"
url: "/articles/tip-show-the-last-git-commit-in-the-site-footer"
type: article
date: 2011-09-27
updated: 2014-05-15
---

# Tip: Show the last git commit in the site footer

#  Tip: Show the last git commit in the site footer 

 By

 [  Andrew Berry   ](/about/andrew-berry) 

 September 27, 2011

  

Here's a quick tip for anyone using Git to version control their Drupal sites. When looking at a development or QA instance of a site, it's useful to be able to see at a glance what the last commit was. With a touch of settings.php code, we can add this information to our site footer.

`// Add the current git revision and date to the site footer.$conf['site_footer'] = '<p>Â©2010 All Rights Reserved<br /><em>';$conf['site_footer'] .= shell_exec("git log -1 --pretty=format:'%h - %s (%ci)' --abbrev-commit");$conf['site_footer'] .= '</em></p>';  `

This code gives us the following footer:

         ![Site footer showing last git commit](/sites/default/files/styles/wide_xs/public/u35/git-commit.jpg.webp?itok=IEHZJyP2 "git-commit.jpg")  

For some of our sites, we also have local branches on development servers that contain specific code for that server. This contains updates to robots.txt or .htaccess to restrict access to the site. Using a local branch breaks the above code, as it will always show the last local commit instead of the last commit that will eventually reach production. Combining `git merge-base` and the backtick operator allows us to show the proper commit message.

  ```

// Add the current git revision and date to the site footer.
$conf['site_footer'] = '<p>Â©2010 All Rights Reserved<br /><em>';
$conf['site_footer'] .= shell_exec("git log -1 --pretty=format:'%h - %s (%ci)' --abbrev-commit `git merge-base local-dev dev`");
$conf['site_footer'] .= '</em></p>';  
```

What other settings.php hacks do you find useful? Share them with us in the comments below!

 Published in:

- [  Drupal Development   ](/topics/drupal-development)
- [  Deployment   ](/topics/deployment)

 

   You must have JavaScript enabled to use this form.

## Get in touch with us

### Tell us about your project. We'd love to hear from you!

 First Name  

 Last Name  

 Your email address  

 Your organization  

 How you heard about us  

 Tell us more 

     Leave this field blank