hub.1 14.6 KB
Newer Older
1 2
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
R
Ryan Tomayko 已提交
3
.
M
Mislav Marohnić 已提交
4
.TH "HUB" "1" "March 2012" "DEFUNKT" "Git Manual"
R
Ryan Tomayko 已提交
5 6
.
.SH "NAME"
C
Chris Wanstrath 已提交
7
\fBhub\fR \- git + hub = github
R
Ryan Tomayko 已提交
8 9
.
.SH "SYNOPSIS"
10
\fBhub\fR [\fB\-\-noop\fR] \fICOMMAND\fR \fIOPTIONS\fR
11 12 13
.
.br
\fBhub alias\fR [\fB\-s\fR] \fISHELL\fR
C
0.3.1  
Chris Wanstrath 已提交
14
.
15
.SS "Expanded git commands:"
16
\fBgit init \-g\fR \fIOPTIONS\fR
C
0.3.1  
Chris Wanstrath 已提交
17 18
.
.br
19
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
R
Ryan Tomayko 已提交
20
.
C
Chris Wanstrath 已提交
21
.br
22
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR]
C
0.3.1  
Chris Wanstrath 已提交
23 24
.
.br
C
Chris Wanstrath 已提交
25 26 27
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
.
.br
28
\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,\.\.\.]
29 30
.
.br
31 32 33
\fBgit checkout\fR \fIPULLREQ\-URL\fR [\fIBRANCH\fR]
.
.br
34 35 36
\fBgit cherry\-pick\fR \fIGITHUB\-REF\fR
.
.br
37 38 39
\fBgit am\fR \fIGITHUB\-URL\fR
.
.br
40 41 42
\fBgit apply\fR \fIGITHUB\-URL\fR
.
.br
43
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR [\fIREF\fR]
C
0.3.1  
Chris Wanstrath 已提交
44 45
.
.br
46 47 48 49
\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
.
.SS "Custom git commands:"
\fBgit create\fR [\fINAME\fR] [\fB\-p\fR] [\fB\-d\fR \fIDESCRIPTION\fR] [\fB\-h\fR \fIHOMEPAGE\fR]
C
0.3.1  
Chris Wanstrath 已提交
50 51
.
.br
52
\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
C
0.3.1  
Chris Wanstrath 已提交
53 54
.
.br
55
\fBgit compare\fR [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR\.\.\.]\fIEND\fR
R
Ryan Tomayko 已提交
56
.
57 58 59
.br
\fBgit fork\fR [\fB\-\-no\-remote\fR]
.
60
.br
61
\fBgit pull\-request\fR [\fB\-f\fR] [\fITITLE\fR|\fB\-i\fR \fIISSUE\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
62
.
R
Ryan Tomayko 已提交
63
.SH "DESCRIPTION"
64
hub enhances various git commands to ease most common workflows with GitHub\.
R
Ryan Tomayko 已提交
65
.
66 67 68
.TP
\fBhub \-\-noop\fR \fICOMMAND\fR
Shows which command(s) would be run as a result of the current command\. Doesn\'t perform anything\.
69
.
70 71 72
.TP
\fBhub alias\fR [\fB\-s\fR] \fISHELL\fR
Writes shell aliasing code for \fISHELL\fR (\fBbash\fR, \fBsh\fR, \fBzsh\fR, \fBcsh\fR) to standard output\. With the \fB\-s\fR option, the output of this command can be evaluated directly within the shell:
73 74 75
.
.br
\fBeval $(hub alias \-s bash)\fR
R
Ryan Tomayko 已提交
76
.
77 78 79
.TP
\fBgit init\fR \fB\-g\fR \fIOPTIONS\fR
Create a git repository as with git\-init(1) and add remote \fBorigin\fR at "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory\'s basename\.
C
Chris Wanstrath 已提交
80
.
81 82
.TP
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR
83
Clone repository "git://github\.com/\fIUSER\fR/\fIREPOSITORY\fR\.git" into \fIDIRECTORY\fR as with git\-clone(1)\. When \fIUSER\fR/ is omitted, assumes your GitHub login\. With \fB\-p\fR, clone private repositories over SSH\. For repositories under your GitHub login, \fB\-p\fR is implicit\.
R
Ryan Tomayko 已提交
84
.
85 86
.TP
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]
M
Mislav Marohnić 已提交
87
Add remote "git://github\.com/\fIUSER\fR/\fIREPOSITORY\fR\.git" as with git\-remote(1)\. When /\fIREPOSITORY\fR is omitted, the basename of the current working directory is used\. With \fB\-p\fR, use private remote "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"\. If \fIUSER\fR is "origin" then uses your GitHub login\.
R
Ryan Tomayko 已提交
88
.
89
.TP
C
Chris Wanstrath 已提交
90
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
91 92
Sets the url of remote \fIREMOTE\-NAME\fR using the same rules as \fBgit remote add\fR\.
.
93 94 95
.TP
\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,\.\.\.]
Adds missing remote(s) with \fBgit remote add\fR prior to fetching\. New remotes are only added if they correspond to valid forks on GitHub\.
C
Chris Wanstrath 已提交
96
.
97 98 99
.TP
\fBgit checkout\fR \fIPULLREQ\-URL\fR [\fIBRANCH\fR]
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 \fIBRANCH\fR\.
100
.
101 102 103
.TP
\fBgit cherry\-pick\fR \fIGITHUB\-REF\fR
Cherry\-pick a commit from a fork using either full URL to the commit or GitHub\-flavored Markdown notation, which is \fBuser@sha\fR\. If the remote doesn\'t yet exist, it will be added\. A \fBgit fetch <user>\fR is issued prior to the cherry\-pick attempt\.
104
.
105 106 107
.TP
\fBgit [am|apply]\fR \fIGITHUB\-URL\fR
Downloads the patch file for the pull request or commit at the URL and applies that patch from disk with \fBgit am\fR or \fBgit apply\fR\. Similar to \fBcherry\-pick\fR, but doesn\'t add new remotes\. \fBgit am\fR creates commits while preserving authorship info while \fBapply\fR only applies the patch to the working copy\.
108
.
109 110 111
.TP
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR [\fIREF\fR]
Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing multiple \fBgit push\fR commands\.
112
.
113 114 115
.TP
\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
Submodule repository "git://github\.com/\fIUSER\fR/\fIREPOSITORY\fR\.git" into \fIDIRECTORY\fR as with git\-submodule(1)\. When \fIUSER\fR/ is omitted, assumes your GitHub login\. With \fB\-p\fR, use private remote "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"\.
C
Chris Wanstrath 已提交
116
.
117 118 119
.TP
\fBgit help\fR
Display enhanced git\-help(1)\.
C
Chris Wanstrath 已提交
120
.
121 122
.P
hub also adds some custom commands that are otherwise not present in git:
M
Mislav Marohnić 已提交
123
.
124 125 126
.TP
\fBgit create\fR [\fINAME\fR] [\fB\-p\fR] [\fB\-d\fR \fIDESCRIPTION\fR] [\fB\-h\fR \fIHOMEPAGE\fR]
Create a new public GitHub repository from the current git repository and add remote \fBorigin\fR at "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory name\. To explicitly name the new repository, pass in \fINAME\fR, optionally in \fIORGANIZATION\fR/\fINAME\fR form to create under an organization you\'re a member of\. With \fB\-p\fR, create a private repository, and with \fB\-d\fR and \fB\-h\fR set the repository\'s description and homepage URL, respectively\.
S
Stephen Celis 已提交
127
.
128 129 130
.TP
\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
Open repository\'s GitHub page in the system\'s default web browser using \fBopen(1)\fR or the \fBBROWSER\fR env variable\. If the repository isn\'t specified, \fBbrowse\fR 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")\.
131
.
132 133 134
.TP
\fBgit compare\fR [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR\.\.\.]\fIEND\fR
Open a GitHub compare view page in the system\'s default web browser\. \fISTART\fR to \fIEND\fR are branch names, tag names, or commit SHA1s specifying the range of history to compare\. If a range with two dots (\fBa\.\.b\fR) is given, it will be transformed into one with three dots\. If \fISTART\fR is omitted, GitHub will compare against the base branch (the default is "master")\.
M
Mislav Marohnić 已提交
135
.
136 137 138
.TP
\fBgit fork\fR [\fB\-\-no\-remote\fR]
Forks the original project (referenced by "origin" remote) on GitHub and adds a new remote for it under your username\. Requires \fBgithub\.token\fR to be set (see CONFIGURATION)\.
139
.
140
.TP
M
Mislav Marohnić 已提交
141 142
\fBgit pull\-request\fR [\fB\-f\fR] [\fITITLE\fR|\fB\-i\fR \fIISSUE\fR|\fIISSUE\-URL\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
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 \fB\-f\fR\.
143 144 145
.
.IP
If \fITITLE\fR 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\.
146 147
.
.IP
M
Mislav Marohnić 已提交
148
If instead of normal \fITITLE\fR an issue number is given with \fB\-i\fR, 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\.
149
.
R
Ryan Tomayko 已提交
150 151 152
.SH "CONFIGURATION"
Use git\-config(1) to display the currently configured GitHub username:
.
153 154
.IP "" 4
.
R
Ryan Tomayko 已提交
155
.nf
C
Chris Wanstrath 已提交
156

157
$ git config \-\-global github\.user
R
Ryan Tomayko 已提交
158 159 160
.
.fi
.
161 162
.IP "" 0
.
R
Ryan Tomayko 已提交
163
.P
164
Or, set the GitHub username and token with:
R
Ryan Tomayko 已提交
165
.
166 167
.IP "" 4
.
R
Ryan Tomayko 已提交
168
.nf
C
Chris Wanstrath 已提交
169

170 171
$ git config \-\-global github\.user <username>
$ git config \-\-global github\.token <token>
R
Ryan Tomayko 已提交
172 173 174
.
.fi
.
175 176
.IP "" 0
.
R
Ryan Tomayko 已提交
177
.P
178 179 180
You can override these values with \fIGITHUB_USER\fR and \fIGITHUB_TOKEN\fR environment variables\.
.
.P
181
See \fIhttp://help\.github\.com/set\-your\-user\-name\-email\-and\-github\-token/\fR for more information\.
C
Chris Wanstrath 已提交
182 183
.
.P
184
If you prefer the HTTPS protocol for GitHub repositories, you can set "hub\.protocol" to "https"\. This will affect \fBclone\fR, \fBfork\fR, \fBremote add\fR and other operations that expand references to GitHub repositories as full URLs that otherwise use git and ssh protocols\.
C
Chris Wanstrath 已提交
185 186 187 188
.
.IP "" 4
.
.nf
C
Chris Wanstrath 已提交
189

190
$ git config \-\-global hub\.protocol https
C
Chris Wanstrath 已提交
191 192 193 194
.
.fi
.
.IP "" 0
R
Ryan Tomayko 已提交
195
.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
.SS "GitHub Enterprise"
By default, hub will only work with repositories that have remotes which point to github\.com\. GitHub Enterprise hosts need to be whitelisted to configure hub to treat such remotes same as github\.com:
.
.IP "" 4
.
.nf

$ git config \-\-global \-\-add hub\.host my\.git\.org
.
.fi
.
.IP "" 0
.
.P
API username and token need also be configured for each Enterprise host:
.
.IP "" 4
.
.nf

$ git config \-\-global github\."my\.git\.org"\.user <username>
$ git config \-\-global github\."my\.git\.org"\.token <token>
.
.fi
.
.IP "" 0
.
.P
The default host for commands like \fBinit\fR and \fBclone\fR is still github\.com, but this can be affected with the \fIGITHUB_HOST\fR environment variable:
.
.IP "" 4
.
.nf

$ GITHUB_HOST=my\.git\.org git clone myproject
.
.fi
.
.IP "" 0
.
C
Chris Wanstrath 已提交
236 237 238 239 240
.SH "EXAMPLES"
.
.SS "git clone"
.
.nf
C
Chris Wanstrath 已提交
241

242
$ git clone schacon/ticgit
243
> git clone git://github\.com/schacon/ticgit\.git
244 245

$ git clone \-p schacon/ticgit
246
> git clone git@github\.com:schacon/ticgit\.git
C
Chris Wanstrath 已提交
247

C
Chris Wanstrath 已提交
248
$ git clone resque
249
> git clone git@github\.com/YOUR_USER/resque\.git
C
Chris Wanstrath 已提交
250 251 252 253 254 255
.
.fi
.
.SS "git remote add"
.
.nf
C
Chris Wanstrath 已提交
256

257
$ git remote add rtomayko
258
> git remote add rtomayko git://github\.com/rtomayko/CURRENT_REPO\.git
259 260

$ git remote add \-p rtomayko
261
> git remote add rtomayko git@github\.com:rtomayko/CURRENT_REPO\.git
C
Chris Wanstrath 已提交
262

C
Chris Wanstrath 已提交
263
$ git remote add origin
264
> git remote add origin git://github\.com/YOUR_USER/CURRENT_REPO\.git
C
Chris Wanstrath 已提交
265 266 267
.
.fi
.
268 269 270 271 272
.SS "git fetch"
.
.nf

$ git fetch mislav
273
> git remote add mislav git://github\.com/mislav/REPO\.git
274 275 276
> git fetch mislav

$ git fetch mislav,xoebus
277 278
> git remote add mislav \.\.\.
> git remote add xoebus \.\.\.
279 280 281 282
> git fetch \-\-multiple mislav xoebus
.
.fi
.
283 284 285 286
.SS "git cherry\-pick"
.
.nf

287 288
$ git cherry\-pick http://github\.com/mislav/REPO/commit/SHA
> git remote add \-f mislav git://github\.com/mislav/REPO\.git
289 290 291
> git cherry\-pick SHA

$ git cherry\-pick mislav@SHA
292
> git remote add \-f mislav git://github\.com/mislav/CURRENT_REPO\.git
293 294 295 296 297 298 299 300
> git cherry\-pick SHA

$ git cherry\-pick mislav@SHA
> git fetch mislav
> git cherry\-pick SHA
.
.fi
.
301
.SS "git am, git apply"
302 303 304 305 306 307 308 309 310 311
.
.nf

$ 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
312 313 314 315

$ git apply https://gist\.github\.com/8da7fb575debd88c54cf
> curl https://gist\.github\.com/8da7fb575debd88c54cf\.txt \-o /tmp/gist\-8da7fb575debd88c54cf\.txt
> git apply /tmp/gist\-8da7fb575debd88c54cf\.txt
316 317 318
.
.fi
.
319 320 321
.SS "git fork"
.
.nf
C
Chris Wanstrath 已提交
322

323
$ git fork
324
[ repo forked on GitHub ]
325
> git remote add \-f YOUR_USER git@github\.com:YOUR_USER/CURRENT_REPO\.git
C
Chris Wanstrath 已提交
326 327 328
.
.fi
.
329 330 331 332 333
.SS "git pull\-request"
.
.nf

# while on a topic branch called "feature":
334 335
$ git pull\-request
[ opens text editor to edit title & body for the request ]
336 337
[ opened pull request on GitHub for "YOUR_USER:feature" ]

338 339
# explicit title, pull base & head:
$ git pull\-request "I\'ve implemented feature X" \-b defunkt:master \-h mislav:feature
340

M
Mislav Marohnić 已提交
341
$ git pull\-request \-i 123
342 343 344 345
[ attached pull request to issue #123 ]
.
.fi
.
346 347 348 349 350 351
.SS "git checkout"
.
.nf

# $ git checkout https://github\.com/defunkt/hub/pull/73
# > git remote add \-f \-t feature git://github:com/mislav/hub\.git
M
Mislav Marohnić 已提交
352
# > git checkout \-\-track \-B mislav\-feature mislav/feature
353 354 355 356 357

# $ git checkout https://github\.com/defunkt/hub/pull/73 custom\-branch\-name
.
.fi
.
C
Chris Wanstrath 已提交
358 359 360 361 362
.SS "git create"
.
.nf

$ git create
363
[ repo created on GitHub ]
364
> git remote add origin git@github\.com:YOUR_USER/CURRENT_REPO\.git
365 366 367 368 369 370 371 372 373 374 375

# 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 已提交
376 377 378
.
.fi
.
379 380 381 382 383 384 385 386 387 388
.SS "git init"
.
.nf

$ git init \-g
> git init
> git remote add origin git@github\.com:YOUR_USER/REPO\.git
.
.fi
.
C
Chris Wanstrath 已提交
389 390 391
.SS "git push"
.
.nf
C
Chris Wanstrath 已提交
392

393
$ git push origin,staging,qa bert_timeout
C
Chris Wanstrath 已提交
394 395
> git push origin bert_timeout
> git push staging bert_timeout
396
> git push qa bert_timeout
C
Chris Wanstrath 已提交
397 398 399
.
.fi
.
C
Chris Wanstrath 已提交
400 401 402
.SS "git browse"
.
.nf
C
Chris Wanstrath 已提交
403

404
$ git browse
J
Justin Quick 已提交
405
> open https://github\.com/YOUR_USER/CURRENT_REPO
406

407 408 409
$ git browse \-\- commit/SHA
> open https://github\.com/YOUR_USER/CURRENT_REPO/commit/SHA

410
$ git browse \-\- issues
J
Justin Quick 已提交
411
> open https://github\.com/YOUR_USER/CURRENT_REPO/issues
412

413
$ git browse schacon/ticgit
414
> open https://github\.com/schacon/ticgit
C
Chris Wanstrath 已提交
415

416 417 418
$ git browse schacon/ticgit commit/SHA
> open https://github\.com/schacon/ticgit/commit/SHA

C
Chris Wanstrath 已提交
419
$ git browse resque
420
> open https://github\.com/YOUR_USER/resque
C
Chris Wanstrath 已提交
421

422
$ git browse resque network
423
> open https://github\.com/YOUR_USER/resque/network
424 425 426 427 428 429 430 431
.
.fi
.
.SS "git compare"
.
.nf

$ git compare refactor
432
> open https://github\.com/CURRENT_REPO/compare/refactor
433

434
$ git compare 1\.0\.\.1\.1
435
> open https://github\.com/CURRENT_REPO/compare/1\.0\.\.\.1\.1
436 437

$ git compare \-u fix
438
> (https://github\.com/CURRENT_REPO/compare/fix)
439

440
$ git compare other\-user patch
441
> open https://github\.com/other\-user/REPO/compare/patch
C
Chris Wanstrath 已提交
442 443 444
.
.fi
.
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
.SS "git submodule"
.
.nf

$ hub submodule add wycats/bundler vendor/bundler
> git submodule add git://github\.com/wycats/bundler\.git vendor/bundler

$ hub submodule add \-p wycats/bundler vendor/bundler
> git submodule add git@github\.com:wycats/bundler\.git vendor/bundler

$ hub submodule add \-b ryppl ryppl/pip vendor/pip
> git submodule add \-b ryppl git://github\.com/ryppl/pip\.git vendor/pip
.
.fi
.
C
Chris Wanstrath 已提交
460 461 462
.SS "git help"
.
.nf
C
Chris Wanstrath 已提交
463

464
$ git help
C
Chris Wanstrath 已提交
465 466
> (improved git help)
$ git help hub
467
> (hub man page)
C
Chris Wanstrath 已提交
468 469 470
.
.fi
.
R
Ryan Tomayko 已提交
471
.SH "BUGS"
472
\fIhttps://github\.com/defunkt/hub/issues\fR
R
Ryan Tomayko 已提交
473
.
474 475
.SH "AUTHORS"
\fIhttps://github\.com/defunkt/hub/contributors\fR
R
Ryan Tomayko 已提交
476 477
.
.SH "SEE ALSO"
478
git(1), git\-clone(1), git\-remote(1), git\-init(1), \fIhttp://github\.com\fR, \fIhttps://github\.com/defunkt/hub\fR