A good[ish] website
Web development blog, loads of UI and JavaScript topics
Have you ever wished it would be possible to initiate a remote repository right from the prompt? With Hub it’s possible.
Hub is really nice. Basically it make life easier by letting you interact with GitHub more from the command line.
Here's some examples what it can do for you:
On a mac the best and easiest install method is via HomeBrew:
$ brew install --HEAD hubHere’s a tutorial on how to install it to a Linux.
Then alias hub with git. Pop open ~/.aliases and add the following to the bottom of the file:
alias git=hubTest if it works:
$ git --version
# If it returns the following, it works
git version 2.0.0
hub version 2.2.0Hub will prompt for GitHub username & password the first time it needs to access the API and exchange it for an OAuth token, which it saves in
~/.config/hub.
Test it quickly by making a test repo:
$ mkdir git-test && cd git-test
$ touch README.md
$ git initNow here’s the sauce:
$ git createThat command will prompt you for a password and a username. For whatever reason, it returned the following error for me:
Post ssh://api.github.com/user/repos: unsupported protocol scheme "ssh"I changes protocol: to https in ~/.config/hub and it worked. The config file should look something like this:
github.com:
- user: bob
    oauth_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    protocol: httpsNote worthy thing: you should authenticate to GitHub with SSH keys, more info in this GitHub tutorial.
Note worthy thing: There’s a little gotcha in setting the protocol to https, now GitHub prompts you a password every time you push or pull, it’s the intended behavior. Either, live with it, or cache your credentials, see GitHub tutorial how to do that.
If you’re unsure what the command does, you can safely test them with the --noop flag:
$ hub --noop create
git remote add -f origin https://github.com/hilja/git-test.git
echo created repository: hilja/git-testIt shows what it does, but actually does nothing.
Here’s an example how the init is different when using hub.
Normal init without hub:
$ init
$ git remote -v
# The git remote command returns nothing cause there is no remoteThen with Hub:
$ git init -g
Initialized empty Git repository in /Users/bob/code/git-test/.git/
$ git remote -v
origin  https://github.com/hilja/git-test.git (fetch)
origin  https://github.com/hilja/git-test.git (push)Hub sets you those remotes automatically.
The create syntax:
git create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE]$ git create -d "This just a test repo, ignore"
origin  https://github.com/hilja/git-test.git (fetch)
origin  https://github.com/hilja/git-test.git (push)
created repository: hilja/git-testThat makes the remote repo.
The browse command will open the project’s GitHub page into your default browser:
$ git browseOr open GitHub issues page:
$ git browse -- issuesOr the pull requests page:
$ git browse -- pullIf it’s your own repo, only a repo name is needed:
$ git clone test-repoNot your own:
$ git clone someone-else/test-repoSee the Hub website for more examples, or the man page for details.
Comments would go here, but the commenting system isn’t ready yet, sorry.