Skip to content

Installing the hub wrapper for git on Linux

lmmx edited this page Dec 14, 2014 · 20 revisions

The installation instructions for github/hub don't consider developers not using Apple OSX / homebrew 😲 You can install the Ruby gem and then sort of install it through that, but it gets awkward because of file permissions.

hub is [currently] a Ruby program, suitable for git > v1.7.3 (git version at time of writing = 1.9.1). The next iteration of hub - version 2.x, "in preview" - is powered by Go.

After installation don't forget to add eval "$(hub alias -s)" to your startup script (.bashrc, .bash_profile etc) to have it alias over the git command.

This simply outputs alias git=hub. Presumably the idea's that if the program fails it won't succesfully assign the alias, so won't break your git

I also don't get why others are creating and using a private bin under the user's home directory: it doesn't seem to be suggested in the hub README any more, so I've replaced it with the standard /usr/bin directory in the script below.

Standalone installation via curl

This link may change, (as it has recently), so I'd try Ruby gem installation but it's cleaner than via the gem. This should work for the Go release in hub v2.x too.

sudo curl https://hub.github.com/standalone -Lo /usr/bin/hub
sudo chmod 755 /usr/bin/hub

Ubuntu path problem

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

Allez hub!

git clone <user>/<repo> is really handy, see the project guide for a comprehensive list of git's new "superpowers".









A bad idea:

Standalone installation via gem

If your Ruby gems version is > v1.3.2 (check with gem -v) you can make life easy take the scenic route to installation with

gem install --user-install git-hub

--user-install only works if you have ~/.gem/ruby/{VERSION}/bin in your PATH.

If you don't you'll be told so, so add this to your shell startup script:

if which ruby >/dev/null && which gem >/dev/null; then
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi

(This is why you shouldn't use sudo gem install. The alternative is RVM)

hub hub standalone > /usr/bin/hub && chmod 755 /usr/bin/hub

For gems < v1.3.2 see here

You could then choose to gem uninstall git-hub (the gem-accessible one is slowed down by Ruby runtime and during installation a message appears, advising "heavy users" to steer clear).

Clone this wiki locally