Displaying git information in Rails

Here is a code snippet that placed within an initializer (for example, in  git_info.rb  at /config/initializers path) can print in your app useful info about the current version of your web app and when it was pushed.

You just have to print them wherever you want.  GITBRANCH  is the branch deployed, GITCOMMIT  is the long SHA hash of the last commit while  GITREVISION  is its short SHA, and  GITLASTUPDATE  is the formatted time when the last commit was pushed.