Git Whereami

gitops meta 
Fri Apr 17 2015

I’ve been traveling a lot for work, and I thought it might be cool to somehow signal where I was physically when checking in code. I knew my Mac has a Geolocation framework, but I couldn’t figure out a way to access it via the command line.

Then I found the wonderful WherAmI project! It’s a simple wrapper around the CoreLocation framework that spits out your lat/lng.

From there, it’s a simple task to pass that up to the Google Geocoding API to get a street address!

Here’s the readme from evantahler/git-whereami


Append your location to all of our git commits!

Do you travel a lot? Would you team be interested to know where your code is coming from? Then this is for you!

Install whereami

Head on over to and download the whereami excecutable. Place it in your home folder, like ~/whereami

1#!/bin/bash 2# prepare-commit-msg 3 4WHEREAMI="$HOME/whereami" 5 6LAT=`$WHEREAMI | grep Latitude | awk -F" " '{print $2}' | awk '{print $1}'` 7LNG=`$WHEREAMI | grep Longitude | awk -F" " '{print $2}' | awk '{print $1}'` 8 9URL="$LAT,$LNG&sensor=false" 10ADDRESS=`eval "curl -s \"$URL\" | grep formatted_address | head -n 1 | sed 's/\"//g' | sed 's/,//g'"` 11ADDRESS=`echo $ADDRESS | awk -F' : ' '{print $2}'` 12DATE=`date` 13 14printf "\n" >> $1 15printf "This commit coded at:\n" >> $1 16printf "---------------------\n" >> $1 17printf "$ADDRESS\n" >> $1 18printf "$LAT, $LNG\n" >> $1 19printf "@ $DATE\n" >> $1

Setup whereami

In whichever git repository you want to use this on, copy the prepare-commit-msg into ~/PROJECT/.git/hooks.

That’s it!

Now, whenever you make a git commit, we will use whereami to source your lat/lng, and then ask Google’s geocoder what your address is, resulting in:

1# Please enter the commit message for your changes. Lines starting 2# with '#' will be ignored, and an empty message aborts the commit. 3# On branch master 4# Your branch is ahead of 'origin/master' by 4 commits. 5# (use "git push" to publish your local commits) 6# 7# Changes to be committed: 8# new file: newfile 9# 10 11This commit coded at: 12--------------------- 1363 Hanbury Street London E1 5JP UK 1451.520182, -0.070440 15@ Fri Apr 17 15:57:03 BST 2015

Feel free to tweak the template as you wish!


  • OSX Only!
Hi, I'm Evan

I write about Technology, Software, and Startups. I use my Product Management, Software Engineering, and Leadership skills to build teams that create world-class digital products.

Get in touch