Recovering from lost git commit messages

I posted a question and answer to stack overflow that explains how to undo the dangerous -c flag in git.

If ever you accidentially overwrite a commit message using git commit –amend, you can easily undo it by search the .git/logs directory. There will still be a hash that points to the previous object which will contain the original message. 



git pre-receive hooks.

In my attempts to block users from committing code as root users which I mentioned in my previous blog post; I’ve identified an unusual behavior in git.


Git pre-receive hooks do not have any parameters passed in, but rather query stdin for parameters.

To demonstrate, create the following file on your git server


set -x

echo "$# parameters have been passed in"


Then try and push code


spencer@workstation:/tmp/hooktest3$ git push
Counting objects: 11, done.

Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (9/9), 731 bytes | 0 bytes/s, done

remote: + echo '0 parameters have been passed in'

The correct way to evaluate the incoming commit is with


while read oldsha newsha refname; do
    case $oldsha,$newsha in
    *,$NULL_SHA1) # it's a delete
        echo "delete request received";;
    $NULL_SHA1,*) # it's a create
       echo creating $newsha";;
    *,*) # it's an update
        echo "updating with $newsha";;

So why is this important?
This is the only way to parse an incoming git commit. You can then evaluate the commit to see who the author is, what type of commit ect..

Thanks go to torek for pointing this out on my stack overflow question here:

Changing the author on git commits

Some of the users at my company have been accidentally creating and pushing git commits as the root user.


While trying to setup a script to block these commits, I found an interesting quirk of git.

Many guides online suggest amending the git author like so:

git commit --amend --author

This unfortunately only changes the author, and not the committer. To prove this I created the following test.

Set the user name and email

git config "bad user" --replace-all
git config ""

Now make a commit and check the  output of git log.

git log
commit bf4343f6a41978ef5c1236c558aeab9415d17601
Author: bad user <>

Change the author

git commit --amend --author "good guy <>"

Check the full output of the last commit. You will notice that while the author is correct, the committer is incorrect.

git log --format=full
commit 52ee52afde053b5c2102760011359dd4ad7fea47
Author: good guy <>
Commit: bad user <>


The correct way to change the author *and* the committer is with the following command:

git config "good guy" --replace-all
git config ""

git commit --amend --reset-author

Now everything works properly

commit 52ee52afde053b5c2102760011359dd4ad7fea47
Author: good guy <>
Commit: good guy <>


Navigate linux ‘info’ command

The command ‘info’ can provide additional information that isn’t present in the man pages. Unfortunately it isn’t easy to navigate.

A trick is learned is to add the following to your ~/.bashrc file

function infos () {
info --vi-keys --subnodes -o - "$@" | less;

Now you can call infos (with an s), to be able to navigate the info page.


$ infos ls

Thanks to Evan Teitelman for pointing this out on unix.stackexchange

Setting up puppet board with Apache

PuppetDB appears to be the way of the future. By leveraging PuppetDB, some enterprising individuals have written a web interface that knocks the socks off of the regular puppet dashboard. It is called puppetboard

Clean and elegant – puppetboard

View of a node

Puppetboard with Apache

Normally puppet board requires Passenger. Here is how to configure puppet board to work with Apache instead.

You can install puppet board on cent with apache using the mod_wsgi plugin

Clone & install  puppetboard

git clone /var/www/puppetboard
sudo yum install python-pip
Install mod_wsgi yum install mod_wsgi.x86_64

(You can see what was installed with the following)
rpm –query –list mod_wsgi.x86_64

Verify that /etc/httpd/confi.d/wdgi.conf exists and has the following content

LoadModule wsgi_module modules/

Add a vhost to /etc/httpd/

$sudo vim /etc/httpd/conf/httpd.conf
<VirtualHost *>
WSGIDaemonProcess puppetboard user=apache group=apache threads=5
 WSGIScriptAlias / /var/www/puppetboard/
<Directory /var/www/puppetboard>
 WSGIProcessGroup puppetboard
 WSGIApplicationGroup %{GLOBAL}
 Order deny,allow
 Allow from all

 Restart Apache
 sudo apachectl -k stop
 sudo /etc/init.d/httpd start

If you are running CentOS/RHEL You get the following errors, it is because the WSGI root path is incorrect.

[Fri Jan 03 16:53:13 2014] [error] [client] (13)Permission denied: mod_wsgi (pid=2029): Unable to connect to WSGI daemon process 'puppetboard' on '/etc/httpd/logs/wsgi.2024.0.1.sock' after multiple attempts.

Add this to /etc/httpd/conf/httpd.conf *before* the vhost

WSGISocketPrefix ../../var/run/wsgi

Restart Apache and puppet board should be installed

Additional Resources!topic/modwsgi/UmNPV-2nQMM

Simplifying git workflows with hub

There is a fantastic application called ‘hub’ which can save a ton of time off of your git workflow.

Normally to clone a git repo, you would enter the following

cd /tmp

git clone -b 4.2-dev

With hub the same command could be executed with the following

cd /tmp

hub clone adaptivecomputing/torque -b 4.2-dev

Since most of the available options for hub match the commands for git, you could even create an alias from hub to replace git.

Just one tip to make your git workflow simpler

Install Gitlab with puppet

Once you have used a professional git hosting service like github, you’ll never be satisfied going back to a plane jane git server like git-web.

git-web is just so darn ugly!


A necessity arose at my company for a way to create pull requests on our main software, so I started investigating how we could migrate our codebase to github.

Unfortunately, github enterprise is $5,000 per 20 users per year. If you have 100 users, thats $25,000 per year!

There are other projects such as gitorious, however their pricing is close to github’s.

Introduce gitlab. Gitlab is an enterprise level git server comparable to gitorious and github enterprise, however costs 1/10th what the competitors charge. They also have a community edition. The only limitations in the community edition being; LDAP group synchronization, and project group invites. Both things a smaller company can live without. See the full feature list here.

Gitlab is light-years ahead of git-web


Installing Gitlab with Puppet

The biggest obstacle to adopting a server like gitlab, is the heavy install. The average time for me to install the community edition of gitlab was 6 hours. So I leveraged puppet to install gitlab automatically.

Using my puppet module, it is now possible to install gitlab in about 15 minutes.

Step by step video tutorial is located below.

Note: You may see the following errors when installing gitlab inside vagrant. This is because dependencies are not resolved when installing a module locally (opposed to from the puppet forge).

vagrant@gitlab:/vagrant$ puppet apply /vagrant/tests/init.pp --debug Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class mysql::server at /vagrant/tests/init.pp:12 on node gitlab.localdomain Wrapped exception: Could not find declared class mysql::server Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class mysql::server at /vagrant/tests/init.pp:12 on node gitlab.localdomain

Solution: Manually install dependencies

puppet module install puppetlabs-mysql

puppet module install puppetlabs-apt

puppet module install example42-postfix

puppet module install puppetlabs-ruby

The spuder-gitlab module can be found on the puppet forge

And the module’s source is on github


Get every new post delivered to your Inbox.