Take a Picture Of Yourself On Every Git Commit – The Git Commit Movie

Intro

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.

https://gist.github.com/pbojinov/6260266

Step 3: Enable permissions

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

 git config --global init.templatedir '~/.git-templates'

2. Create our hooks folder for the post-commit template.

mkdir -p ~/.git-templates/hooks

3. Add the post-commit file in ~/.git-templates/hooks/. We can use the same script from above in step 2.

4. Make our post-commit executable. We are giving it executable permission to all users in this case.

sudo chmod +x ~/.git-templates/hooks/post-commit

5. Start committing and smiling. Every time we  git init, we now have the post-commit hook in all of our new repos.

Nice to Have

Here are some things I am looking into:

  • Store pictures from all repos into one folder instead of in each individual repo. eg. in ~/.commit_images
  • More to come…

Stitching It All Together (Movie Time)

More details in the link, but we can essentially use ffmpeg to create a short stop motion video of our commit images.

http://www.itforeveryone.co.uk/image-to-video.html

Final Product (The Movie)

I am planning on adding my own video when I amass some pictures, but in the mean time here is a short video sample.

 

Special Thanks

  • Víctor Martínez – https://coderwall.com/p/xlatfq (original idea)
  • Damon Davison – https://coderwall.com/p/l3kwta (bash script)
  • Matt Venables – https://coderwall.com/p/jp7d5q (global solution)
  • Lolcommits – http://mroth.github.io/lolcommits/
Advertisement

5 thoughts on “Take a Picture Of Yourself On Every Git Commit – The Git Commit Movie

  1. Pingback: Git Shots, Chronicles of Coding – Short Film | Petar Bojinov

  2. Thanks for a marvelous posting! I genuinely enjoyed reading it, you’re a great author.
    I will be sure to bookmark your blog and will come back very soon.
    I want to encourage you to definitely continue your great writing, have
    a nice afternoon!

  3. Hi would you mind stating which blog platform you’re using?
    I’m planning to start my own blog soon but I’m having a
    tough time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most
    blogs and I’m looking for something completely unique. P.S Apologies for
    getting off-topic but I had to ask!

  4. Pingback: Making of COPE – Bernhard Rode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s