Skip to content

Instantly share code, notes, and snippets.

@mlewand
Last active October 23, 2017 14:29
Show Gist options
  • Save mlewand/a281245e91e6f8ed35a4c83eac3cf741 to your computer and use it in GitHub Desktop.
Save mlewand/a281245e91e6f8ed35a4c83eac3cf741 to your computer and use it in GitHub Desktop.
Notes to an overview of hub CLI tool.

hub Overview

Project page is available at http://github.com/github/hub.

Docs https://hub.github.com/hub.1.html.

Most Useful Things

My personal favs are:

  • Issue creation
  • PR creation
  • Forking for quick contributions

Forking Repositories

Let's do a quick fork of a stevemao/left-pad repo.

  1. hub clone stevemao/left-pad
  2. cd left-pad
  3. hub fork

Now we can add just a random file, push it and see if it works.

Pro tip, you could use hub browse to open it from CLI.

Could be simplified down to a single command, see Automation Opportunities.

Creating Repos

  • mkdir foo
  • cd foo
  • hub init
  • hub create -d "My repository description" [-p]

You can view it with hub browse.

Creating Issues

hub issue create or ois

Problems?

  • Files drag and drop - it's better to do that directly in GH.

Making Pull Requests

  • hub pull-request create
    • How to abort PR?
  • hub pull-request create --push or opr --push

How about PRs with base other than master?

opr --push -b <baseBranch> -l "bug,help wanted"

Demo Time

How about emojis in issues? See CKE5 issue template

Automation Opportunities

Forking in a single command could be further simplified with some Bash ugliness:

gh-fork() {
  hub clone "$1"
  cd "${1##*/}"
  hub fork
}

Configuration

Yes, it takes longer than 2hrs to get everything going. But from there, creating issues is just a breeze.

For me it was mainly about:

  • Setting up VSCode to be a default editor.
  • Adding aliases like ois, cis, opr, cpr.

Gotchas

  • core.commentChar - by default it's set to # (unfortunately emoji won't work 😁).
  • Remember about key management (pageant on Windows), otherwise you'll have to type your pass all over the place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment