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

## SYNOPSIS

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

C
Chris Wanstrath 已提交
9
`git init -g` <OPTIONS>  
10
`git create` [<NAME>] [`-p`] [`-d` <DESCRIPTION>] [`-h` <HOMEPAGE>]  
C
Chris Wanstrath 已提交
11 12
`git clone` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>  
`git remote add` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>]  
13
`git remote set-url` [`-p`] <OPTIONS> <REMOTE-NAME> <USER>[/<REPOSITORY>]  
14
`git fetch` <USER-1>,[<USER-2>,...]  
15
`git cherry-pick` <GITHUB-REF>  
16
`git am` <GITHUB-URL>  
17
`git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]  
18 19
`git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]  
`git compare` [`-u`] [<USER>] [<START>...]<END>  
C
Chris Wanstrath 已提交
20
`git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>  
21
`git fork` [`--no-remote`]  
R
Ryan Tomayko 已提交
22 23 24 25 26 27

## DESCRIPTION

`hub` enhances various `git` commands with GitHub remote expansion. The
alias command displays information on configuring your environment:

28
  * `hub alias` [`-s`] <SHELL>:
29 30
    Writes shell aliasing code for <SHELL> (`bash`, `sh`, `zsh`,
    `csh`) to standard output. With the `-s` option, the output of
31
    this command can be evaluated directly within the shell:  
R
Ryan Tomayko 已提交
32 33
    `eval $(hub alias -s bash)`

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

39 40
  * `git create` [<NAME>] [`-p`] [`-d` <DESCRIPTION>] [`-h` <HOMEPAGE>]:  
    Create a new public GitHub repository from the current git
41 42
    repository and add remote `origin` at
    "git@github.com:<USER>/<REPOSITORY>.git"; <USER> is your GitHub
43 44 45 46 47
    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.
48

M
Mislav Marohnić 已提交
49
  * `git clone` [`-p`] <OPTIONS> [<USER>`/`]<REPOSITORY> <DIRECTORY>:  
50
    Clone repository "git://github.com/<USER>/<REPOSITORY>.git" into
C
Chris Wanstrath 已提交
51 52 53
    <DIRECTORY> as with git-clone(1). When <USER>/ is omitted, assumes
    your GitHub login. With `-p`, use private remote
    "git@github.com:<USER>/<REPOSITORY>.git".
R
Ryan Tomayko 已提交
54

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

62 63 64 65
  * `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`.

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

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

76 77 78 79 80
  * `git am` <GITHUB-URL>:
    Downloads the patch file for the pull request or commit at the URL and
    applies that patch from disk with `git am`. Similar to `cherry-pick`, but
    doesn't add new remotes.

81
  * `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]:
82 83 84
    Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
    multiple `git push` commands.

85 86 87 88 89 90 91
  * `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").
92

93
  * `git compare` [`-u`] [<USER>] [<START>...]<END>:
C
Chris Wanstrath 已提交
94
    Open a GitHub compare view page in the system's default web browser.
J
Joshua Roesslein 已提交
95
    <START> to <END> are branch names, tag names, or commit SHA1s specifying
96 97 98
    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 已提交
99

M
Mislav Marohnić 已提交
100
  * `git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>:  
S
Stephen Celis 已提交
101 102 103 104 105
    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".

106
  * `git fork` [`--no-remote`]:
107 108 109
    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).
110

111
  * `git help`:
R
Ryan Tomayko 已提交
112 113 114 115 116 117 118 119
    Display enhanced git-help(1).

## CONFIGURATION

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

    $ git config --global github.user

120
Or, set the GitHub username and token with:
R
Ryan Tomayko 已提交
121 122

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

C
Chris Wanstrath 已提交
125 126 127 128 129 130
See <http://github.com/guides/local-github-config> for more
information.

You can also tell `hub` to use `http://` rather than `git://` when
cloning:

131
    $ git config --global --bool hub.http-clone true
R
Ryan Tomayko 已提交
132

133 134 135 136 137 138 139 140
Want to use environment variables instead of a local gitconfig for
authentication?

* `GITHUB_USER`  - If set, this will be used instead of the `github.user` config
                   value to determine your GitHub username.
* `GITHUB_TOKEN` - If set, this will be used instead of the `github.token`
                   config value to determine your GitHub API token.

C
Chris Wanstrath 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
## EXAMPLES

### git clone

    $ git clone schacon/ticgit
    > git clone git://github.com/schacon/ticgit.git

    $ git clone -p schacon/ticgit
    > git clone git@github.com:schacon/ticgit.git

    $ git clone resque
    > git clone git://github.com/YOUR_USER/resque.git

    $ git clone -p resque
    > git clone git@github.com:YOUR_USER/resque.git

### git remote add

    $ git remote add rtomayko
    > git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git

    $ git remote add -p rtomayko
    > git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git

165
    $ git remote add origin
C
Chris Wanstrath 已提交
166
    > git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git
167

168 169 170 171 172 173 174 175 176 177 178
### git fetch

    $ git fetch mislav
    > git remote add mislav git://github.com/mislav/REPO.git
    > git fetch mislav

    $ git fetch mislav,xoebus
    > git remote add mislav ...
    > git remote add xoebus ...
    > git fetch --multiple mislav xoebus

179 180 181 182 183 184 185 186 187 188 189 190 191 192
### git cherry-pick

    $ git cherry-pick http://github.com/mislav/REPO/commit/SHA
    > git remote add -f mislav git://github.com/mislav/REPO.git
    > git cherry-pick SHA

    $ git cherry-pick mislav@SHA
    > git remote add -f mislav git://github.com/mislav/CURRENT_REPO.git
    > git cherry-pick SHA

    $ git cherry-pick mislav@SHA
    > git fetch mislav
    > git cherry-pick SHA

193 194 195 196 197 198 199 200 201 202
### git am

    $ git am https://github.com/defunkt/hub/pull/55
    > curl https://github.com/defunkt/hub/pull/55.patch -o /tmp/55.patch
    > git am /tmp/55.patch

    $ git am --ignore-whitespace https://github.com/davidbalbert/hub/commit/fdb9921
    > curl https://github.com/davidbalbert/hub/commit/fdb9921.patch -o /tmp/fdb9921.patch
    > git am --ignore-whitespace /tmp/fdb9921.patch

203 204 205
### git fork

    $ git fork
206
    [ repo forked on GitHub ]
207 208
    > git remote add YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git

C
Chris Wanstrath 已提交
209 210 211 212 213 214
### git init

    $ git init -g
    > git init
    > git remote add origin git@github.com:YOUR_USER/REPO.git

215 216 217
### git create

    $ git create
218
    [ repo created on GitHub ]
219 220
    > git remote add origin git@github.com:YOUR_USER/CURRENT_REPO.git

221 222 223 224 225 226 227 228 229 230 231
    # with description:
    $ git create -d 'It shall be mine, all mine!'

    $ git create recipes
    [ repo created on GitHub ]
    > git remote add origin git@github.com:YOUR_USER/recipes.git

    $ git create sinatra/recipes
    [ repo created in GitHub organization ]
    > git remote add origin git@github.com:sinatra/recipes.git

C
Chris Wanstrath 已提交
232 233 234 235 236 237 238
### git push

    $ git push origin,staging,qa bert_timeout
    > git push origin bert_timeout
    > git push staging bert_timeout
    > git push qa bert_timeout

239 240
### git browse

241
    $ git browse
J
Justin Quick 已提交
242
    > open https://github.com/YOUR_USER/CURRENT_REPO
243

244 245 246
    $ git browse -- commit/SHA
    > open https://github.com/YOUR_USER/CURRENT_REPO/commit/SHA

247
    $ git browse -- issues
J
Justin Quick 已提交
248
    > open https://github.com/YOUR_USER/CURRENT_REPO/issues
249

250
    $ git browse schacon/ticgit
251
    > open https://github.com/schacon/ticgit
252

253 254 255
    $ git browse schacon/ticgit commit/SHA
    > open https://github.com/schacon/ticgit/commit/SHA

256
    $ git browse resque
257
    > open https://github.com/YOUR_USER/resque
258

259
    $ git browse resque network
260
    > open https://github.com/YOUR_USER/resque/network
261

J
Joshua Roesslein 已提交
262 263 264
### git compare

    $ git compare refactor
265
    > open https://github.com/CURRENT_REPO/compare/refactor
J
Joshua Roesslein 已提交
266

267
    $ git compare 1.0..1.1
268
    > open https://github.com/CURRENT_REPO/compare/1.0...1.1
J
Joshua Roesslein 已提交
269 270

    $ git compare -u fix
271
    > (https://github.com/CURRENT_REPO/compare/fix)
J
Joshua Roesslein 已提交
272

273
    $ git compare other-user patch
274
    > open https://github.com/other-user/REPO/compare/patch
J
Joshua Roesslein 已提交
275

C
Chris Wanstrath 已提交
276 277 278 279 280 281 282
### git help

    $ git help
    > (improved git help)
    $ git help hub
    > (hub man page)

R
Ryan Tomayko 已提交
283 284 285 286
## BUGS

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

C
Chris Wanstrath 已提交
287
## AUTHORS
R
Ryan Tomayko 已提交
288

C
Chris Wanstrath 已提交
289
<https://github.com/defunkt/hub/contributors>
R
Ryan Tomayko 已提交
290 291 292 293 294 295

## SEE ALSO

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