Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

197 lines (149 sloc) 8.21 KB
hub(1) -- git + hub = github
`hub` [`--noop`] <COMMAND> <OPTIONS>
`hub alias` [`-s`] [<SHELL>]
### Expanded git commands:
`git init -g` <OPTIONS>
`git clone` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>
`git remote add` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>]
`git remote set-url` [`-p`] <OPTIONS> <REMOTE-NAME> <USER>[/<REPOSITORY>]
`git fetch` <USER-1>,[<USER-2>,...]
`git checkout` <PULLREQ-URL> [<BRANCH>]
`git merge` <PULLREQ-URL>
`git cherry-pick` <GITHUB-REF>
`git am` <GITHUB-URL>
`git apply` <GITHUB-URL>
`git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]
`git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>
### Custom git commands:
`git create` [<NAME>] [`-p`] [`-d` <DESCRIPTION>] [`-h` <HOMEPAGE>]
`git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]
`git compare` [`-u`] [<USER>] [<START>...]<END>
`git fork` [`--no-remote`]
`git pull-request` [`-f`] [<TITLE>|`-i` <ISSUE>] [`-b` <BASE>] [`-h` <HEAD>]
hub enhances various git commands to ease most common workflows with GitHub.
* `hub --noop` <COMMAND>:
Shows which command(s) would be run as a result of the current command.
Doesn't perform anything.
* `hub alias` [`-s`] [<SHELL>]:
Shows shell instructions for wrapping git. If given, <SHELL> specifies the
type of shell; otherwise defaults to the value of SHELL environment
variable. With `-s`, outputs shell script suitable for `eval`.
* `git init` `-g` <OPTIONS>:
Create a git repository as with git-init(1) and add remote `origin` at
"<USER>/<REPOSITORY>.git"; <USER> is your GitHub username and
<REPOSITORY> is the current working directory's basename.
* `git clone` [`-p`] <OPTIONS> [<USER>`/`]<REPOSITORY> <DIRECTORY>:
Clone repository "git://<USER>/<REPOSITORY>.git" into
<DIRECTORY> as with git-clone(1). When <USER>/ is omitted, assumes
your GitHub login. With `-p`, clone private repositories over SSH.
For repositories under your GitHub login, `-p` is implicit.
* `git remote add` [`-p`] <OPTIONS> <USER>[`/`<REPOSITORY>]:
Add remote "git://<USER>/<REPOSITORY>.git" as with
git-remote(1). When /<REPOSITORY> is omitted, the basename of the
current working directory is used. With `-p`, use private remote
"<USER>/<REPOSITORY>.git". If <USER> is "origin"
then uses your GitHub login.
* `git remote set-url` [`-p`] <OPTIONS> <REMOTE-NAME> <USER>[/<REPOSITORY>]:
Sets the url of remote <REMOTE-NAME> using the same rules as
`git remote add`.
* `git fetch` <USER-1>,[<USER-2>,...]:
Adds missing remote(s) with `git remote add` prior to fetching. New
remotes are only added if they correspond to valid forks on GitHub.
* `git checkout` <PULLREQ-URL> [<BRANCH>]:
Checks out the head of the pull request as a local branch, to allow for
reviewing, rebasing and otherwise cleaning up the commits in the pull
request before merging. The name of the local branch can explicitly be
set with <BRANCH>.
* `git merge` <PULLREQ-URL>:
Merge the pull request with a commit message that includes the pull request
ID and title, similar to the GitHub Merge Button.
* `git cherry-pick` <GITHUB-REF>:
Cherry-pick a commit from a fork using either full URL to the commit
or GitHub-flavored Markdown notation, which is `user@sha`. If the remote
doesn't yet exist, it will be added. A `git fetch <user>` is issued
prior to the cherry-pick attempt.
* `git [am|apply]` <GITHUB-URL>:
Downloads the patch file for the pull request or commit at the URL and
applies that patch from disk with `git am` or `git apply`. Similar to
`cherry-pick`, but doesn't add new remotes. `git am` creates commits while
preserving authorship info while `apply` only applies the patch to the
working copy.
* `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]:
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
multiple `git push` commands.
* `git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>:
Submodule repository "git://<USER>/<REPOSITORY>.git" into
<DIRECTORY> as with git-submodule(1). When <USER>/ is omitted, assumes
your GitHub login. With `-p`, use private remote
* `git help`:
Display enhanced git-help(1).
hub also adds some custom commands that are otherwise not present in git:
* `git create` [<NAME>] [`-p`] [`-d` <DESCRIPTION>] [`-h` <HOMEPAGE>]:
Create a new public GitHub repository from the current git
repository and add remote `origin` at
"<USER>/<REPOSITORY>.git"; <USER> is your GitHub
username and <REPOSITORY> is the current working directory name.
To explicitly name the new repository, pass in <NAME>, optionally in
<ORGANIZATION>/<NAME> form to create under an organization you're a
member of. With `-p`, create a private repository, and with `-d` and `-h`
set the repository's description and homepage URL, respectively.
* `git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]:
Open repository's GitHub page in the system's default web browser using
`open(1)` or the `BROWSER` env variable. If the repository isn't
specified, `browse` opens the page of the repository found in the current
directory. If SUBPAGE is specified, the browser will open on the specified
subpage: one of "wiki", "commits", "issues" or other (the default is
* `git compare` [`-u`] [<USER>] [<START>...]<END>:
Open a GitHub compare view page in the system's default web browser.
<START> to <END> are branch names, tag names, or commit SHA1s specifying
the range of history to compare. If a range with two dots (`a..b`) is given,
it will be transformed into one with three dots. If <START> is omitted,
GitHub will compare against the base branch (the default is "master").
* `git fork` [`--no-remote`]:
Forks the original project (referenced by "origin" remote) on GitHub and
adds a new remote for it under your username.
* `git pull-request` [`-f`] [<TITLE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]:
Opens a pull request on GitHub for the project that the "origin" remote
points to. The default head of the pull request is the current branch.
Both base and head of the pull request can be explicitly given in one of
the following formats: "branch", "owner:branch", "owner/repo:branch".
This command will abort operation if it detects that the current topic
branch has local commits that are not yet pushed to its upstream branch
on the remote. To skip this check, use `-f`.
If <TITLE> is omitted, a text editor will open in which title and body of
the pull request can be entered in the same manner as git commit message.
If instead of normal <TITLE> an issue number is given with `-i`, the pull
request will be attached to an existing GitHub issue. Alternatively, instead
of title you can paste a full URL to an issue on GitHub.
Hub 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".
If you prefer the HTTPS protocol for GitHub repositories, you can set
"hub.protocol" to "https". This will affect `clone`, `fork`, `remote add`
and other operations that expand references to GitHub repositories as full
URLs that otherwise use git and ssh protocols.
$ git config --global hub.protocol https
### GitHub Enterprise
By default, hub will only work with repositories that have remotes which
point to GitHub Enterprise hosts need to be whitelisted to
configure hub to treat such remotes same as
$ git config --global --add
The default host for commands like `init` and `clone` is still, but this can be affected with the <GITHUB_HOST> environment
$ git clone myproject
git(1), git-clone(1), git-remote(1), git-init(1),
Jump to Line
Something went wrong with that request. Please try again.