hub.1.ronn 9.0 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` [`-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>  
C
Chris Wanstrath 已提交
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

M
Mislav Marohnić 已提交
39
  * `git create` [`-p`] [`-d <DESCRIPTION>`] [`-h <HOMEPAGE>`]:  
40 41 42 43 44 45 46
    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's
    basename. With `-p`, create a private repository. `-d` and `-h`
    set the repository's description and homepage, respectively.

M
Mislav Marohnić 已提交
47
  * `git clone` [`-p`] <OPTIONS> [<USER>`/`]<REPOSITORY> <DIRECTORY>:  
48
    Clone repository "git://github.com/<USER>/<REPOSITORY>.git" into
C
Chris Wanstrath 已提交
49 50 51
    <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 已提交
52

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

60 61 62 63
  * `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`.

64 65 66 67
  * `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.

68 69 70 71 72 73
  * `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.

74 75 76 77 78
  * `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.

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

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

91
  * `git compare` [`-u`] [<USER>] [<START>...]<END>:
C
Chris Wanstrath 已提交
92
    Open a GitHub compare view page in the system's default web browser.
J
Joshua Roesslein 已提交
93
    <START> to <END> are branch names, tag names, or commit SHA1s specifying
94 95
    the range of history to compare. If <START> is omitted, GitHub will
    compare against the base branch (the default is "master").
J
Joshua Roesslein 已提交
96

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

103
  * `git fork` [`--no-remote`]:
104 105 106
    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).
107

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

## CONFIGURATION

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

    $ git config --global github.user

117
Or, set the GitHub username and token with:
R
Ryan Tomayko 已提交
118 119

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

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

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

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

130 131 132 133 134 135 136 137
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 已提交
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
## 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

162
    $ git remote add origin
C
Chris Wanstrath 已提交
163
    > git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git
164

165 166 167 168 169 170 171 172 173 174 175
### 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

176 177 178 179 180 181 182 183 184 185 186 187 188 189
### 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

190 191 192 193 194 195 196 197 198 199
### 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

200 201 202 203 204 205
### git fork

    $ git fork
    ... hardcore forking action ...
    > git remote add YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git

C
Chris Wanstrath 已提交
206 207 208 209 210 211
### git init

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

212 213 214 215 216 217
### git create

    $ git create
    ... hardcore creating action ...
    > git remote add origin git@github.com:YOUR_USER/CURRENT_REPO.git

C
Chris Wanstrath 已提交
218 219 220 221 222 223 224
### git push

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

225 226
### git browse

227
    $ git browse
J
Justin Quick 已提交
228
    > open https://github.com/YOUR_USER/CURRENT_REPO
229 230

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

233
    $ git browse schacon/ticgit
234
    > open https://github.com/schacon/ticgit
235 236

    $ git browse resque
237
    > open https://github.com/YOUR_USER/resque
238

239
    $ git browse resque network
240
    > open https://github.com/YOUR_USER/resque/network
241

J
Joshua Roesslein 已提交
242 243 244
### git compare

    $ git compare refactor
245
    > open https://github.com/CURRENT_REPO/compare/refactor
J
Joshua Roesslein 已提交
246 247

    $ git compare 1.0...1.1
248
    > open https://github.com/CURRENT_REPO/compare/1.0...1.1
J
Joshua Roesslein 已提交
249 250

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

253
    $ git compare other-user patch
254
    > open https://github.com/other-user/REPO/compare/patch
J
Joshua Roesslein 已提交
255

C
Chris Wanstrath 已提交
256 257 258 259 260 261 262
### git help

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

R
Ryan Tomayko 已提交
263 264 265 266
## BUGS

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

C
Chris Wanstrath 已提交
267
## AUTHORS
R
Ryan Tomayko 已提交
268

C
Chris Wanstrath 已提交
269
<https://github.com/defunkt/hub/contributors>
R
Ryan Tomayko 已提交
270 271 272 273 274 275

## SEE ALSO

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