hub
Interact with GitHub from the command line
TLDR
Clone a repository using its slug (owners can omit the username)
Create a fork of the current repository (cloned from another user) under your GitHub profile
Push the current local branch to GitHub and create a PR for it in the original repository
Create a PR of the current (already pushed) branch, reusing the message from the first commit
Create a new branch with the contents of a pull request and switch to it
Upload the current (local-only) repository to your GitHub account
Fetch Git objects from upstream and update local branches
SYNOPSIS
hub [OPTIONS]
hub [OPTIONS]
hub
typically acts as a proxy for git
. You can often use it as a direct replacement for git
(e.g., hub push
instead of git push
) where it transparently adds its enhancements. It also introduces its own specific subcommands like hub pull-request
, hub fork
, or hub browse
.
PARAMETERS
--version
Show hub's version and exit.
--help
Show hub's help message or a subcommand's help.
[GIT_COMMAND]
Any standard Git command (e.g., clone
, remote
, pull
) that hub
intercepts to provide GitHub-specific enhancements, such as automatic URL resolution.
[HUB_COMMAND]
A specific command provided by hub
itself (e.g., pull-request
, fork
, browse
, compare
) to interact directly with the GitHub API or simplify GitHub-centric workflows.
DESCRIPTION
hub
is a command-line wrapper for Git that makes it significantly easier to interact with GitHub directly from your terminal. Instead of manually constructing complex Git commands with full GitHub URLs, hub
simplifies common tasks by providing intelligent shortcuts and GitHub-specific commands. For instance, you can often use hub clone user/repo
instead of git clone https://github.com/user/repo.git
. It introduces powerful new commands like hub pull-request
to create a pull request directly from your current branch, hub fork
to fork a repository, or hub browse
to open the repository in your web browser. hub
aims to extend Git's core capabilities, streamlining your development workflow by deeply integrating with GitHub's functionalities and reducing manual URL construction, making the command-line experience with GitHub intuitive and efficient.
CAVEATS
hub
requires a GitHub API token for many of its interactive operations that modify GitHub (e.g., creating pull requests, forking). While still functional, hub
has largely been superseded by GitHub's official gh
CLI tool, which offers a more comprehensive and actively developed set of features for interacting with GitHub beyond just Git enhancements. Users might find gh
to be a more modern and robust option for most GitHub command-line interactions today.
HOW IT WORKS
hub
functions by intercepting calls that would normally go to the git
command. When you execute hub
, hub
first checks if
is one of its own built-in commands (like pull-request
). If it's not a hub
-specific command, it then attempts to pass the command directly to the underlying git
binary, often injecting additional arguments or environment variables to enable GitHub-specific behaviors (e.g., automatically resolving repository URLs from shorthand notations). This intelligent interception allows users to configure an alias (e.g., alias git=hub
in their shell) to seamlessly use hub
's enhanced capabilities for all their Git commands without changing their habits.
HISTORY
hub
was created by Mislav Marohnić and quickly became a highly popular and indispensable command-line interface for GitHub users. Its development aimed to bridge the usability gap between local Git operations and remote GitHub workflows, making common tasks like creating pull requests, forking repositories, and navigating projects on GitHub significantly simpler directly from the terminal. For many years, it served as the unofficial standard for GitHub command-line interaction. Although still functional, its active development has considerably slowed since the introduction of the official GitHub CLI (gh
) by GitHub, which now fulfills the primary role for GitHub command-line tooling.