$ cat "

Git Commit Script for the Lazy Typist

"

If you are a git user, you are probably a fan of the command line, and you probably use aliases to make your daily work more efficient. One of my most frequently used aliases is gc, which is an alias for git commit -m.


alias gc='git commit -m'


However, one shortcoming of this alias is that you still have to add the double quotes, which is tedious.


gc "this is a commit message"


There are several ways of solving that problem, and I chose to do it by writing a small ruby script:


#!/usr/bin/ruby

# Performs a git commit with all the command line arguments as a message,
# for example:
# gcm this is a commit message => git commit -m "this is a commit message"

message = ARGV.join(" ")
%x[git commit -m '#{message}']


By saving this script with a suitable name in some directory that is part of your path you can now commit with messages without quotes.

The commit shown above now becomes:


gc this is a commit message


You can find this script and more up at github where I keep my configuration, such as bash scripts and dot files.

Written by Erik Öjebo 2010-12-04 16:59

    Comments