Using the Hub in Github - Pull Requests

Hub is a command line tool that wraps around the git command. It add’s some cool features that make working with git easier. The goal of this post is to show how easy it is to generate a pull request. But i’ll also quickly explain how to install hub itself.

Hub is written in Go! So we need to install this to get started. You can download the latest package/source here

$ sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
$ vi ~/.bashrc

export PATH=$PATH:/usr/local/go/bin

With that in place we can setup hub

$ git clone
$ cd hub
$ ./script/build
$ cp hub /usr/local/bin
$ hub --version

git version 1.9.1
hub version 2.2.0-rc1-13-g111100c

If you are used to the git command like me. It might be a good idea to setup a alias for hub

$ vi ~/.bashrc

alias git=hub

One other thing i had to do because we work with the Github Enterprise Edition. Is to whtelist our github host.

$ git config --global --add github.dome.domain

Creating a pull request with hub is as easy as using the Github web gui. We start of with creating a fork of an existing repository

$ git clone git@github.some.domain:user/FOO.git
$ cd FOO
$ git fork

This created the remote fork. And sets the correct remotes for the local repository

$ git remote -v

origin git@github.some.domain:user/FOO.git (fetch)
origin git@github.some.domain:user/FOO.git (push)
me git@github.some.domain:me/FOO.git (fetch)
me git@github.some.domain:me/FOO.git (push)

Before we can generate a pull request we ofcourse need some changes to push.

$ git branch bar
$ git checkout bar
$ touch BAR
$ git add BAR
$ git commit -am "Add BAR"
$ git push me bar

Total 0 (delta 0), reused 0 (delta 0)
To git@github.some.domain:me/FOO.git
* [new branch] bar -> bar

The only thing left to do is create the actual pull-request

$ git pull-request


comments powered by Disqus