Git Aliases Rock

Published 18 February 09 by Justin French

Most of you Git users probably already know about Git aliases. Typically you add a few lines to ~/.gitconfig and you can alias git co to git checkout, etc:

[alias]
   co = checkout
   st = status
   ci = commit

But you can also use it to run shell commands by prefixing the alias with an exclamation mark (!), my first of which was aliasing git df to git diff | mate to pipe the diff into TextMate, which gives me pretty colors and a familiar environment:

df = !git diff | mate

Mostly I’m just lazy. I’d prefer to type git save mystashname instead of git stash save mystashname, and git pop instead of git stash pop, because I find myself stashing a lot of stuff and like to give them proper names, etc etc. It’s totally awesome that I can make Git work for me.

The most crazy one I’ve been experimenting with so far wraps up a common pattern I have, which is…

  1. switching back to the master branch from my generic “dev” branch
  2. pulling from the remote
  3. switching back to “dev”
  4. rebasing “dev” against “master”
  5. switching back to “master”
  6. merging in the changes from “dev”
  7. and finally running git wtf to show me what all my branches look like after the merge before I do a push.

I call this git publish:

publish = !git checkout master && git pull && git checkout dev && git rebase master && git checkout master && git merge dev && git wtf

Get lazy! Go make Git and bash do the hard work for you!

Options

What is this?

portrait of Justin

This is the online home of Justin French, a designer & web application developer located in Melbourne, Australia. I like finding ways to make things work better. I like clarifying and simplifying. I like to understand how you understand things.

» read more

Subscribe to my feed

Follow me on Twitter

@justinfrench

More Notebook Articles

Show more notebook articles

Search