January 29, 2013

git me and git wholog - useful git aliases for viewing commits

When using git, it is a common requirement to be able to get a log of all the commits that you have done or some one else has done. I find the git --committer a little long to type in and use every time, with a little bash-foo you can have simple aliases like "git me" and "git wholog " to do the same. The changes for this would be : 



if [ $# -gt 0 ]; then
        if [ "$1" == "me" ]; then
                exec git log --committer='Satish'
        elif [ "$1" == "wholog" ]; then
                if [ $# -lt 2 ]; then
                        echo "usage: git wholog "
                        exit 1
                exec git log --committer=$2
                exec git $@


alias git='~/bin/git`

Run "source ~/.bashrc" and you are all set to go.

In retrospect, this could have been done much more neatly with "git config --global alias.xxxx".


  1. There is a simpler way to do it.
    Creating a script `git-anything` will let you execute `git anything`!

    $vim git-me
    git log --committer='Satish'

    put it in /usr/bin

    $ git me # and it works

  2. I would not put a user specific alias in a system folder and also, I still think using the git alias functionality is a cleaner way of doing this.