back to listing index

hub · the command-line wrapper for git

[web search]
Original source (
Tags: os-x git Mac command-line tools github
Clipped on: 2014-11-12

hub makes git better with GitHub

Documentation: man hub

hub is a command-line wrapper for git that makes you better at GitHub.

# install on OS X for 2.x preview
$ brew install --HEAD hub

# install from source for 2.x preview
# you need  a Go development environment:
$ git clone
$ cd hub
$ ./script/build
$ cp hub YOUR_BIN_PATH

# install on OS X for 1.x
$ brew install hub

# install from source for 1.x
$ git clone
$ git checkout 1.12-stable
$ cd hub
$ rake install prefix=/usr/local

# alias it as git
$ alias git=hub

$ git version
git version 1.7.9
hub version 1.11.0 # ← it works!

As a contributor to open-source

Whether you are beginner or an experienced contributor to open-source, hub makes it easier to fetch repositories, navigate project pages, fork repos and even submit pull requests, all from the command-line.

# clone your own project
$ git clone dotfiles
→ git clone git://

# clone another project
$ git clone github/hub
→ git clone git://

# see the current project's issues
$ git browse -- issues
→ open

# open another project's wiki
$ git browse mojombo/jekyll wiki
→ open
# Example workflow for contributing to a project:
$ git clone github/hub
$ cd hub
# create a topic branch
$ git checkout -b feature
  ( making changes ... )
$ git commit -m "done with feature"

# It's time to fork the repo!
$ git fork
→ (forking repo on GitHub...)
→ git remote add YOUR_USER git://

# push the changes to your new remote
$ git push YOUR_USER feature
# open a pull request for the topic branch you've just pushed
$ git pull-request
→ (opens a text editor for your pull request message)

As an open-source maintainer

Maintaining a project is easier when you can easily fetch from other forks, review pull requests and cherry-pick URLs. You can even create a new repo for your next thing.

# fetch from multiple trusted forks, even if they don't yet exist as remotes
$ git fetch mislav,cehoffman
→ git remote add mislav git://
→ git remote add cehoffman git://
→ git fetch --multiple mislav cehoffman

# check out a pull request for review
$ git checkout
→ (creates a new branch with the contents of the pull request)

# directly apply all commits from a pull request to the current branch
$ git am -3

# cherry-pick a GitHub URL
$ git cherry-pick
→ git remote add xoebus git://
→ git fetch xoebus
→ git cherry-pick 177eeb8

# `am` can be better than cherry-pick since it doesn't create a remote
$ git am

# open the GitHub compare view between two releases
$ git compare v0.9..v1.0

# put compare URL for a topic branch to clipboard
$ git compare -u feature | pbcopy

# create a repo for a new project
$ git init
$ git add . && git commit -m "It begins."
$ git create -d "My new thing"
→ (creates a new project on GitHub with the name of current directory)
$ git push origin master

One who uses GitHub for work

Save time at work by opening pull requests for code reviews and pushing to multiple remotes at once. Even GitHub Enterprise is supported.

# whitelist your GitHub Enterprise hostname
$ git config --global --add

# open a pull request for a branch, put its URL to the clipboard
$ git push origin feature
$ git pull-request | pbcopy
→ (URL ready for pasting in a chat room)

# push to multiple remotes
$ git push production,staging

hub is maintained by mislav. source code located on github.