hub: The Legacy GitHub Wrapper CLI
hub wraps git with GitHub features like hub pull-request; it is in maintenance mode and gh is the recommended replacement.
hub predates gh and still appears in older pipelines. It aliases git and adds GitHub commands. Know its token variable and its main verbs, but prefer gh for new work.
What it does
hub extends git: hub pull-request opens a PR, hub ci-status prints the combined status of the current commit, hub fork forks a repo, and hub release manages releases. Setting alias hub=git lets it stand in for git.
Common usage
# open a PR non-interactively (message avoids the editor)
GITHUB_TOKEN="$GH_PAT" hub pull-request -m "Add feature X" -b main -h feature-x
# check CI status of the current commit
hub ci-status --verboseOptions
| Command / Flag | What it does |
|---|---|
| hub pull-request -m <msg> | Open a PR with an inline message (no editor) |
| -b <base> | Base branch |
| -h <head> | Head branch |
| hub ci-status [--verbose] | Print combined status of the current commit |
| GITHUB_TOKEN | Env var hub reads for authentication |
In CI
Always pass -m so hub pull-request does not open an editor and hang. hub reads GITHUB_TOKEN from the environment. Because hub is in maintenance mode, migrate to gh pr create / gh pr checks for anything new; hub still works but no new features land.
Common errors in CI
"Error creating pull request: Unauthorized (HTTP 401)" means GITHUB_TOKEN is missing or invalid. "Aborted: the pull request already exists" is a duplicate PR. "Error: unknown command" for a modern verb means you are relying on a gh-only feature; use gh. An editor opening means you omitted -m.