git ready

learn git one commit at a time
by Nick Quaranto

helpful command aliases

committed 06 Feb 2009

A great way to make your life using Git easier is to add aliases for commands that you use all the time into your .gitconfig file. It might not be as elegant as adding shortcuts to your shell, but at least this will work consistently across all shells and is a breeze to set up. The Git Cheat Sheet suggests adding this block to your config file:

[alias]
  st = status
  ci = commit
  br = branch
  co = checkout
  df = diff
  lg = log -p

Once you’ve got this block added to your config file, it should work immediately:

$ git st
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#  _posts/2009-02-06-helpful-command-aliases.textile
nothing added to commit but untracked files present (use "git add" to track)

You can also add aliases like so, and they will get added to your .gitconfig file automatically.

$ git config --global alias.rb rebase

For the SVN converts, Alex Soto has suggested a few alias helpers that will help with interacting with Subversion repositories:

[alias]
  spull = !git-svn fetch && git-svn rebase
  spush = !git-svn dcommit

There’s also plenty of other advanced commands at the GitWiki. If you’ve got an alias that others could find useful, comment or submit away and it will be added!