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
.
.br
13
\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
.TP
71 72
\fBhub alias\fR [\fB\-s\fR] [\fISHELL\fR]
Shows shell instructions for wrapping git\. If given, \fISHELL\fR specifies the type of shell; otherwise defaults to the value of SHELL environment variable\. With \fB\-s\fR, outputs shell script suitable for \fBeval\fR\.
R
Ryan Tomayko 已提交
73
.
74 75 76
.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 已提交
77
.
78 79
.TP
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR
80
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 已提交
81
.
82 83
.TP
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]
M
Mislav Marohnić 已提交
84
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 已提交
85
.
86
.TP
C
Chris Wanstrath 已提交
87
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
88 89
Sets the url of remote \fIREMOTE\-NAME\fR using the same rules as \fBgit remote add\fR\.
.
90 91 92
.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 已提交
93
.
94 95 96
.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\.
97
.
98 99 100
.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\.
101
.
102 103 104
.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\.
105
.
106 107 108
.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\.
109
.
110 111 112
.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 已提交
113
.
114 115 116
.TP
\fBgit help\fR
Display enhanced git\-help(1)\.
C
Chris Wanstrath 已提交
117
.
118 119
.P
hub also adds some custom commands that are otherwise not present in git:
M
Mislav Marohnić 已提交
120
.
121 122 123
.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 已提交
124
.
125 126 127
.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")\.
128
.
129 130 131
.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ć 已提交
132
.
133 134 135
.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)\.
136
.
137
.TP
M
Mislav Marohnić 已提交
138 139
\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\.
140 141 142
.
.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\.
143 144
.
.IP
M
Mislav Marohnić 已提交
145
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\.
146
.
R
Ryan Tomayko 已提交
147 148 149
.SH "CONFIGURATION"
Use git\-config(1) to display the currently configured GitHub username:
.
150 151
.IP "" 4
.
R
Ryan Tomayko 已提交
152
.nf
C
Chris Wanstrath 已提交
153

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

167 168
$ git config \-\-global github\.user <username>
$ git config \-\-global github\.token <token>
R
Ryan Tomayko 已提交
169 170 171
.
.fi
.
172 173
.IP "" 0
.
R
Ryan Tomayko 已提交
174
.P
175 176 177
You can override these values with \fIGITHUB_USER\fR and \fIGITHUB_TOKEN\fR environment variables\.
.
.P
178
See \fIhttp://help\.github\.com/set\-your\-user\-name\-email\-and\-github\-token/\fR for more information\.
C
Chris Wanstrath 已提交
179 180
.
.P
181
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 已提交
182 183 184 185
.
.IP "" 4
.
.nf
C
Chris Wanstrath 已提交
186

187
$ git config \-\-global hub\.protocol https
C
Chris Wanstrath 已提交
188 189 190 191
.
.fi
.
.IP "" 0
R
Ryan Tomayko 已提交
192
.
193 194 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
.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 已提交
233 234 235 236 237
.SH "EXAMPLES"
.
.SS "git clone"
.
.nf
C
Chris Wanstrath 已提交
238

239
$ git clone schacon/ticgit
240
> git clone git://github\.com/schacon/ticgit\.git
241 242

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

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

254
$ git remote add rtomayko
255
> git remote add rtomayko git://github\.com/rtomayko/CURRENT_REPO\.git
256 257

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

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

$ git fetch mislav
270
> git remote add mislav git://github\.com/mislav/REPO\.git
271 272 273
> git fetch mislav

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

284 285
$ git cherry\-pick http://github\.com/mislav/REPO/commit/SHA
> git remote add \-f mislav git://github\.com/mislav/REPO\.git
286 287 288
> git cherry\-pick SHA

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

$ git cherry\-pick mislav@SHA
> git fetch mislav
> git cherry\-pick SHA
.
.fi
.
298
.SS "git am, git apply"
299 300 301 302 303 304 305 306 307 308
.
.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
309 310 311 312

$ 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
313 314 315
.
.fi
.
316 317 318
.SS "git fork"
.
.nf
C
Chris Wanstrath 已提交
319

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

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

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

M
Mislav Marohnić 已提交
338
$ git pull\-request \-i 123
339 340 341 342
[ attached pull request to issue #123 ]
.
.fi
.
343 344 345 346 347 348
.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ć 已提交
349
# > git checkout \-\-track \-B mislav\-feature mislav/feature
350 351 352 353 354

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

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

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

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

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

401
$ git browse
J
Justin Quick 已提交
402
> open https://github\.com/YOUR_USER/CURRENT_REPO
403

404 405 406
$ git browse \-\- commit/SHA
> open https://github\.com/YOUR_USER/CURRENT_REPO/commit/SHA

407
$ git browse \-\- issues
J
Justin Quick 已提交
408
> open https://github\.com/YOUR_USER/CURRENT_REPO/issues
409

410
$ git browse schacon/ticgit
411
> open https://github\.com/schacon/ticgit
C
Chris Wanstrath 已提交
412

413 414 415
$ git browse schacon/ticgit commit/SHA
> open https://github\.com/schacon/ticgit/commit/SHA

C
Chris Wanstrath 已提交
416
$ git browse resque
417
> open https://github\.com/YOUR_USER/resque
C
Chris Wanstrath 已提交
418

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

$ git compare refactor
429
> open https://github\.com/CURRENT_REPO/compare/refactor
430

431
$ git compare 1\.0\.\.1\.1
432
> open https://github\.com/CURRENT_REPO/compare/1\.0\.\.\.1\.1
433 434

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

437
$ git compare other\-user patch
438
> open https://github\.com/other\-user/REPO/compare/patch
C
Chris Wanstrath 已提交
439 440 441
.
.fi
.
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
.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 已提交
457 458 459
.SS "git help"
.
.nf
C
Chris Wanstrath 已提交
460

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