Favorite Hub Aliases For Git

Hub is a command line tool that extends git with Github specific commands, and also some other git enhancements but this post is just about the Github aspect. I originally thought it was not useful but I gave it a try and after a few months, it’s now part of my everyday tool kit.

Hub can easily be installed on OSX with:

brew install hub

Once finished, now you’re off to the races. I added all these aliases to my .gitconfig.

Open A Pull Request

I always open pull requests from the command line, it’s so efficient and quick it’s almost magic. My work flow is like so:

git chb new-feature # checkout new branch
git a # adds all changes to staging
git c "My commit"
git pb # pushed branch to remote
git pr "Pull request name"


    chb = checkout -b
    a = add -A
    c = commit -m
    pb = !git push -u origin $(git rev-parse --abbrev-ref HEAD)
    pr = !hub pull-request -m

Check Continuous Integration Status

This shortcut will check the CI status of the current branch. I run this some time after opening a pull request.


    ci = !hub ci-status -v

View Current Branch

Some times I need to see the current branch on Github or I just want to open the repo in the browser. You’ll use this more often than you think.


    view =  !hub browse -- tree/$(git rev-parse --abbrev-ref HEAD)

Code Request Pull Request

When someone asks me to code review a pull request, I now always ask for the number so I can open it from the command line.

git cr #{pull-request-number}


    cr =  !hub browse -- pull/"$1"/files


I hope you find these command as useful as me. If you want to see my full git config, it is open source.

Related Posts

Test Your Chinese Using This Quiz

Using Sidekiq Iteration and Unique Jobs

Using Radicale with Gnome Calendar

Why I Regret Switching from Jekyll to Middleman for My Blog

Pick Random Item Based on Probability

Quickest Way to Incorporate in Ontario

Creating Chinese Study Decks

Generating Better Random Numbers

Image Magick Tricks

My Game Dev Process