hub.1.ronn 7.9 KB
Newer Older
R
Ryan Tomayko 已提交
1 2 3 4 5
hub(1) -- git + hub = github
============================

## SYNOPSIS

6
`hub` [`--noop`] <COMMAND> <OPTIONS>  
C
Chris Wanstrath 已提交
7
`hub alias` [`-s`] <SHELL>
R
Ryan Tomayko 已提交
8

9 10
### Expanded git commands:

C
Chris Wanstrath 已提交
11 12 13
`git init -g` <OPTIONS>  
`git clone` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>  
`git remote add` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>]  
14
`git remote set-url` [`-p`] <OPTIONS> <REMOTE-NAME> <USER>[/<REPOSITORY>]  
15
`git fetch` <USER-1>,[<USER-2>,...]  
16
`git checkout` <PULLREQ-URL> [<BRANCH>]  
17
`git cherry-pick` <GITHUB-REF>  
18
`git am` <GITHUB-URL>  
19
`git apply` <GITHUB-URL>  
20
`git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]  
21 22 23 24 25
`git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>  

### Custom git commands:

`git create` [<NAME>] [`-p`] [`-d` <DESCRIPTION>] [`-h` <HOMEPAGE>]  
26 27
`git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]  
`git compare` [`-u`] [<USER>] [<START>...]<END>  
28
`git fork` [`--no-remote`]  
M
Mislav Marohnić 已提交
29
`git pull-request` [`-f`] [<TITLE>|`-i` <ISSUE>] [`-b` <BASE>] [`-h` <HEAD>]:  
R
Ryan Tomayko 已提交
30 31 32

## DESCRIPTION

33
hub enhances various git commands to ease most common workflows with GitHub.
R
Ryan Tomayko 已提交
34

35 36 37 38
  * `hub --noop` <COMMAND>:
    Shows which command(s) would be run as a result of the current command.
    Doesn't perform anything.

39
  * `hub alias` [`-s`] <SHELL>:
40 41
    Writes shell aliasing code for <SHELL> (`bash`, `sh`, `zsh`,
    `csh`) to standard output. With the `-s` option, the output of
42
    this command can be evaluated directly within the shell:  
R
Ryan Tomayko 已提交
43 44
    `eval $(hub alias -s bash)`

45
  * `git init` `-g` <OPTIONS>:
R
Ryan Tomayko 已提交
46
    Create a git repository as with git-init(1) and add remote `origin` at
47 48
    "git@github.com:<USER>/<REPOSITORY>.git"; <USER> is your GitHub username and
    <REPOSITORY> is the current working directory's basename.
R
Ryan Tomayko 已提交
49

50
  * `git clone` [`-p`] <OPTIONS> [<USER>`/`]<REPOSITORY> <DIRECTORY>:
51
    Clone repository "git://github.com/<USER>/<REPOSITORY>.git" into
C
Chris Wanstrath 已提交
52
    <DIRECTORY> as with git-clone(1). When <USER>/ is omitted, assumes
53 54
    your GitHub login. With `-p`, clone private repositories over SSH.
    For repositories under your GitHub login, `-p` is implicit.
R
Ryan Tomayko 已提交
55

56
  * `git remote add` [`-p`] <OPTIONS> <USER>[`/`<REPOSITORY>]:
57 58
    Add remote "git://github.com/<USER>/<REPOSITORY>.git" as with
    git-remote(1). When /<REPOSITORY> is omitted, the basename of the
R
Ryan Tomayko 已提交
59
    current working directory is used. With `-p`, use private remote
60 61
    "git@github.com:<USER>/<REPOSITORY>.git". If <USER> is "origin"
    then uses your GitHub login.
R
Ryan Tomayko 已提交
62

63
  * `git remote set-url` [`-p`] <OPTIONS> <REMOTE-NAME> <USER>[/<REPOSITORY>]:
64 65 66
    Sets the url of remote <REMOTE-NAME> using the same rules as 
    `git remote add`.

67 68 69 70
  * `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.

71 72 73 74 75 76
  * `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>.

77 78 79 80 81 82
  * `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.

83
  * `git [am|apply]` <GITHUB-URL>:
84
    Downloads the patch file for the pull request or commit at the URL and
85 86 87 88
    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.
89

90
  * `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]:
91 92 93
    Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
    multiple `git push` commands.

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
  * `git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>:
    Submodule repository "git://github.com/<USER>/<REPOSITORY>.git" into
    <DIRECTORY> as with git-submodule(1). When <USER>/ is omitted, assumes
    your GitHub login. With `-p`, use private remote
    "git@github.com:<USER>/<REPOSITORY>.git".

  * `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
    "git@github.com:<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.

115 116 117 118 119 120 121
  * `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
    "tree").
122

123
  * `git compare` [`-u`] [<USER>] [<START>...]<END>:
C
Chris Wanstrath 已提交
124
    Open a GitHub compare view page in the system's default web browser.
J
Joshua Roesslein 已提交
125
    <START> to <END> are branch names, tag names, or commit SHA1s specifying
126 127 128
    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").
J
Joshua Roesslein 已提交
129

130
  * `git fork` [`--no-remote`]:
131 132 133
    Forks the original project (referenced by "origin" remote) on GitHub and
    adds a new remote for it under your username. Requires `github.token` to
    be set (see CONFIGURATION).
134

135 136
  * `git pull-request` [`-f`] [<TITLE>|`-i` <ISSUE>] [`-b` <BASE>] [`-h` <HEAD>]:
    `git pull-request` [`-f`] <ISSUE-URL> [`-h` <HEAD>]
137 138 139 140
    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".
141 142 143 144 145 146
    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.
147

M
Mislav Marohnić 已提交
148 149 150
    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.
151

R
Ryan Tomayko 已提交
152 153 154 155 156 157
## CONFIGURATION

Use git-config(1) to display the currently configured GitHub username:

    $ git config --global github.user

158
Or, set the GitHub username and token with:
R
Ryan Tomayko 已提交
159 160

    $ git config --global github.user <username>
161
    $ git config --global github.token <token>
R
Ryan Tomayko 已提交
162

163 164 165
You can override these values with <GITHUB_USER> and <GITHUB_TOKEN>
environment variables.

C
Chris Wanstrath 已提交
166 167 168
See <http://github.com/guides/local-github-config> for more
information.

169 170 171 172
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.
173

174
    $ git config --global hub.protocol https
175

C
Chris Wanstrath 已提交
176 177
## EXAMPLES

178
{{README}}
C
Chris Wanstrath 已提交
179

R
Ryan Tomayko 已提交
180 181 182 183
## BUGS

<http://github.com/defunkt/hub/issues>

C
Chris Wanstrath 已提交
184
## AUTHORS
R
Ryan Tomayko 已提交
185

C
Chris Wanstrath 已提交
186
<https://github.com/defunkt/hub/contributors>
R
Ryan Tomayko 已提交
187 188 189 190 191 192

## SEE ALSO

git(1), git-clone(1), git-remote(1), git-init(1),
<http://github.com>,
<http://github.com/defunkt/hub>