Late last year I was browsing around on Coderwall and came across a cool idea to take a picture of yourself using your webcam everytime you commit some code to git. For the non-technical person, this means that every time you make some changes to a project you are working on, you get to take a shameless seflie! What better way to connect the programmatic world to visual arts than this?
Six months and 302 commits later, after “filming” non-stop all over the world, and by all over the world I mean at work, on the BART, at home and other random places in the San Francisco Bay Area since August of 2013, I am proud to present you my short film, “Git Shots, Chronicles of Coding”.
Interested in remembering every one of your commits?
Setting it up was a challenge due to the fragmented information scattered among many different sources, so I ended up writing a blog post on how to set it up yourself.
I am always trying to connect programming to film & media in any way I can, so what better way than to take a picture of myself with my laptop’s webcam every time I commit some code.
Using a couple commands in terminal and a basic script, you can automate the process, so all you have to do is sit back, commit some code and be photogenic.
In this tutorial, I have compiled the best of other tutorials, gotchas, and related content I have come across on the web. At the end of this, you can even star you in your own git commit movie.
Getting Started
Just a heads up, this is geared towards OSX users… for everyone else, I will add more details when I come across Linux, Windows info 🙂
Step 1: Install imagesnap
brew install imagesnap
Step 2: Create post-commit hook
Add the following code from the gist below to a file called post-commit in your repo’s ~/.git/hooks/ folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Lets give the file some permission (making it executable by everyone).
sudo chmod +x ~/.git/hooks/post-commit
Step 4: Start committing and smiling
On first run, the script will create a folder called commit_images in your repo’s root. Then every time you commit code, a photo is added to the folder and to .gitignore automatically so you don’t have to.
Current Downfall
The only downfall to this solution is you have to add it to each of your git repos manually. So if you have a lot of repos it might be a pain, but then again thats what writing a script is for, right? So behold…the global solution (for new repos)!
Global Solution
1. Enable git templates. This will copy everything in the .git-templates folder to any new git repositories when you git init