hub.1 12.8 KB
Newer Older
1 2
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
R
Ryan Tomayko 已提交
3
.
4
.TH "HUB" "1" "October 2011" "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
.
C
Chris Wanstrath 已提交
15
.P
16
\fBgit init \-g\fR \fIOPTIONS\fR
C
0.3.1  
Chris Wanstrath 已提交
17 18
.
.br
19
\fBgit create\fR [\fINAME\fR] [\fB\-p\fR] [\fB\-d\fR \fIDESCRIPTION\fR] [\fB\-h\fR \fIHOMEPAGE\fR]
20 21 22
.
.br
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
R
Ryan Tomayko 已提交
23
.
C
Chris Wanstrath 已提交
24
.br
25
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR]
C
0.3.1  
Chris Wanstrath 已提交
26 27
.
.br
C
Chris Wanstrath 已提交
28 29 30
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
.
.br
31
\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,\.\.\.]
32 33
.
.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
\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
C
0.3.1  
Chris Wanstrath 已提交
47 48
.
.br
49
\fBgit compare\fR [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR\.\.\.]\fIEND\fR
C
0.3.1  
Chris Wanstrath 已提交
50 51
.
.br
52
\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
R
Ryan Tomayko 已提交
53
.
54 55 56
.br
\fBgit fork\fR [\fB\-\-no\-remote\fR]
.
57 58 59
.br
\fBgit pull\-request\fR [\fITITLE\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
.
R
Ryan Tomayko 已提交
60
.SH "DESCRIPTION"
61
\fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion\. The alias command displays information on configuring your environment:
R
Ryan Tomayko 已提交
62
.
C
Chris Wanstrath 已提交
63
.IP "\(bu" 4
64 65 66
\fBhub \-\-noop\fR \fICOMMAND\fR: Shows which command(s) would be run as a result of the current command\. Doesn\'t perform anything\.
.
.IP "\(bu" 4
67
\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:
68 69 70
.
.br
\fBeval $(hub alias \-s bash)\fR
R
Ryan Tomayko 已提交
71
.
C
Chris Wanstrath 已提交
72
.IP "\(bu" 4
73
\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\.
R
Ryan Tomayko 已提交
74
.
C
Chris Wanstrath 已提交
75
.IP "\(bu" 4
76
\fBgit create\fR [\fINAME\fR] [\fB\-p\fR] [\fB\-d\fR \fIDESCRIPTION\fR] [\fB\-h\fR \fIHOMEPAGE\fR]:
M
Mislav Marohnić 已提交
77 78
.
.br
79
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\.
C
Chris Wanstrath 已提交
80 81
.
.IP "\(bu" 4
M
Mislav Marohnić 已提交
82 83 84 85
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR:
.
.br
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, use private remote "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"\.
R
Ryan Tomayko 已提交
86
.
C
Chris Wanstrath 已提交
87
.IP "\(bu" 4
M
Mislav Marohnić 已提交
88 89 90 91
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]:
.
.br
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 已提交
92
.
C
Chris Wanstrath 已提交
93 94 95 96
.IP "\(bu" 4
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
.
.br
97 98 99 100
Sets the url of remote \fIREMOTE\-NAME\fR using the same rules as \fBgit remote add\fR\.
.
.IP "\(bu" 4
\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 已提交
101 102
.
.IP "\(bu" 4
103
\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
.
C
Chris Wanstrath 已提交
105
.IP "\(bu" 4
106
\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\.
107
.
C
Chris Wanstrath 已提交
108
.IP "\(bu" 4
109
\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\.
110
.
C
Chris Wanstrath 已提交
111
.IP "\(bu" 4
112
\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")\.
C
Chris Wanstrath 已提交
113
.
C
Chris Wanstrath 已提交
114
.IP "\(bu" 4
115
\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")\.
C
Chris Wanstrath 已提交
116
.
C
Chris Wanstrath 已提交
117
.IP "\(bu" 4
M
Mislav Marohnić 已提交
118 119 120 121
\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR:
.
.br
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"\.
S
Stephen Celis 已提交
122
.
C
Chris Wanstrath 已提交
123
.IP "\(bu" 4
124
\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)\.
125
.
C
Chris Wanstrath 已提交
126
.IP "\(bu" 4
127 128 129 130 131 132 133 134 135
\fBgit pull\-request\fR [\fITITLE\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]:
.
.br
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"\.
.
.IP
If instead of normal \fITITLE\fR a string in "#\fINUMBER\fR" format is given, the pull request will be attached to an existing GitHub issue whose ID corresponds to \fINUMBER\fR\.
.
.IP "\(bu" 4
136
\fBgit help\fR: Display enhanced git\-help(1)\.
R
Ryan Tomayko 已提交
137
.
C
Chris Wanstrath 已提交
138 139
.IP "" 0
.
R
Ryan Tomayko 已提交
140 141 142
.SH "CONFIGURATION"
Use git\-config(1) to display the currently configured GitHub username:
.
143 144
.IP "" 4
.
R
Ryan Tomayko 已提交
145
.nf
C
Chris Wanstrath 已提交
146

147
$ git config \-\-global github\.user
R
Ryan Tomayko 已提交
148 149 150
.
.fi
.
151 152
.IP "" 0
.
R
Ryan Tomayko 已提交
153
.P
154
Or, set the GitHub username and token with:
R
Ryan Tomayko 已提交
155
.
156 157
.IP "" 4
.
R
Ryan Tomayko 已提交
158
.nf
C
Chris Wanstrath 已提交
159

160 161
$ git config \-\-global github\.user <username>
$ git config \-\-global github\.token <token>
R
Ryan Tomayko 已提交
162 163 164
.
.fi
.
165 166
.IP "" 0
.
R
Ryan Tomayko 已提交
167
.P
168
See \fIhttp://github\.com/guides/local\-github\-config\fR for more information\.
C
Chris Wanstrath 已提交
169 170
.
.P
171
You can also tell \fBhub\fR to use \fBhttp://\fR rather than \fBgit://\fR when cloning:
C
Chris Wanstrath 已提交
172 173 174 175
.
.IP "" 4
.
.nf
C
Chris Wanstrath 已提交
176

177
$ git config \-\-global \-\-bool hub\.http\-clone true
C
Chris Wanstrath 已提交
178 179 180 181
.
.fi
.
.IP "" 0
R
Ryan Tomayko 已提交
182
.
183 184 185 186 187 188 189 190 191 192 193
.P
Want to use environment variables instead of a local gitconfig for authentication?
.
.IP "\(bu" 4
\fBGITHUB_USER\fR \- If set, this will be used instead of the \fBgithub\.user\fR config
.
.IP "\(bu" 4
\fBGITHUB_TOKEN\fR \- If set, this will be used instead of the \fBgithub\.token\fR
.
.IP "" 0
.
C
Chris Wanstrath 已提交
194 195 196 197 198
.SH "EXAMPLES"
.
.SS "git clone"
.
.nf
C
Chris Wanstrath 已提交
199

200
$ git clone schacon/ticgit
201
> git clone git://github\.com/schacon/ticgit\.git
202 203

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

C
Chris Wanstrath 已提交
206
$ git clone resque
207
> git clone git://github\.com/YOUR_USER/resque\.git
C
Chris Wanstrath 已提交
208

209
$ git clone \-p resque
210
> git clone git@github\.com:YOUR_USER/resque\.git
C
Chris Wanstrath 已提交
211 212 213 214 215 216
.
.fi
.
.SS "git remote add"
.
.nf
C
Chris Wanstrath 已提交
217

218
$ git remote add rtomayko
219
> git remote add rtomayko git://github\.com/rtomayko/CURRENT_REPO\.git
220 221

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

C
Chris Wanstrath 已提交
224
$ git remote add origin
225
> git remote add origin git://github\.com/YOUR_USER/CURRENT_REPO\.git
C
Chris Wanstrath 已提交
226 227 228
.
.fi
.
229 230 231 232 233
.SS "git fetch"
.
.nf

$ git fetch mislav
234
> git remote add mislav git://github\.com/mislav/REPO\.git
235 236 237
> git fetch mislav

$ git fetch mislav,xoebus
238 239
> git remote add mislav \.\.\.
> git remote add xoebus \.\.\.
240 241 242 243
> git fetch \-\-multiple mislav xoebus
.
.fi
.
244 245 246 247
.SS "git cherry\-pick"
.
.nf

248 249
$ git cherry\-pick http://github\.com/mislav/REPO/commit/SHA
> git remote add \-f mislav git://github\.com/mislav/REPO\.git
250 251 252
> git cherry\-pick SHA

$ git cherry\-pick mislav@SHA
253
> git remote add \-f mislav git://github\.com/mislav/CURRENT_REPO\.git
254 255 256 257 258 259 260 261
> git cherry\-pick SHA

$ git cherry\-pick mislav@SHA
> git fetch mislav
> git cherry\-pick SHA
.
.fi
.
262
.SS "git am, git apply"
263 264 265 266 267 268 269 270 271 272
.
.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
273 274 275 276

$ 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
277 278 279
.
.fi
.
280 281 282
.SS "git fork"
.
.nf
C
Chris Wanstrath 已提交
283

284
$ git fork
285
[ repo forked on GitHub ]
286
> git remote add \-f YOUR_USER git@github\.com:YOUR_USER/CURRENT_REPO\.git
C
Chris Wanstrath 已提交
287 288 289
.
.fi
.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
.SS "git pull\-request"
.
.nf

# while on a topic branch called "feature":
$ git pull\-request "I\'ve implemented feature X"
[ opened pull request on GitHub for "YOUR_USER:feature" ]

# explicit pull base & head:
$ git pull\-request \-b defunkt:master \-h mislav:feature

$ git pull\-request #123
[ attached pull request to issue #123 ]
.
.fi
.
C
Chris Wanstrath 已提交
306 307 308 309 310
.SS "git create"
.
.nf

$ git create
311
[ repo created on GitHub ]
312
> git remote add origin git@github\.com:YOUR_USER/CURRENT_REPO\.git
313 314 315 316 317 318 319 320 321 322 323

# 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 已提交
324 325 326
.
.fi
.
327 328 329 330 331 332 333 334 335 336
.SS "git init"
.
.nf

$ git init \-g
> git init
> git remote add origin git@github\.com:YOUR_USER/REPO\.git
.
.fi
.
C
Chris Wanstrath 已提交
337 338 339
.SS "git push"
.
.nf
C
Chris Wanstrath 已提交
340

341
$ git push origin,staging,qa bert_timeout
C
Chris Wanstrath 已提交
342 343
> git push origin bert_timeout
> git push staging bert_timeout
344
> git push qa bert_timeout
C
Chris Wanstrath 已提交
345 346 347
.
.fi
.
C
Chris Wanstrath 已提交
348 349 350
.SS "git browse"
.
.nf
C
Chris Wanstrath 已提交
351

352
$ git browse
J
Justin Quick 已提交
353
> open https://github\.com/YOUR_USER/CURRENT_REPO
354

355 356 357
$ git browse \-\- commit/SHA
> open https://github\.com/YOUR_USER/CURRENT_REPO/commit/SHA

358
$ git browse \-\- issues
J
Justin Quick 已提交
359
> open https://github\.com/YOUR_USER/CURRENT_REPO/issues
360

361
$ git browse schacon/ticgit
362
> open https://github\.com/schacon/ticgit
C
Chris Wanstrath 已提交
363

364 365 366
$ git browse schacon/ticgit commit/SHA
> open https://github\.com/schacon/ticgit/commit/SHA

C
Chris Wanstrath 已提交
367
$ git browse resque
368
> open https://github\.com/YOUR_USER/resque
C
Chris Wanstrath 已提交
369

370
$ git browse resque network
371
> open https://github\.com/YOUR_USER/resque/network
372 373 374 375 376 377 378 379
.
.fi
.
.SS "git compare"
.
.nf

$ git compare refactor
380
> open https://github\.com/CURRENT_REPO/compare/refactor
381

382
$ git compare 1\.0\.\.1\.1
383
> open https://github\.com/CURRENT_REPO/compare/1\.0\.\.\.1\.1
384 385

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

388
$ git compare other\-user patch
389
> open https://github\.com/other\-user/REPO/compare/patch
C
Chris Wanstrath 已提交
390 391 392
.
.fi
.
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
.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 已提交
408 409 410
.SS "git help"
.
.nf
C
Chris Wanstrath 已提交
411

412
$ git help
C
Chris Wanstrath 已提交
413 414
> (improved git help)
$ git help hub
415
> (hub man page)
C
Chris Wanstrath 已提交
416 417 418
.
.fi
.
R
Ryan Tomayko 已提交
419
.SH "BUGS"
420
\fIhttp://github\.com/defunkt/hub/issues\fR
R
Ryan Tomayko 已提交
421
.
422 423
.SH "AUTHORS"
\fIhttps://github\.com/defunkt/hub/contributors\fR
R
Ryan Tomayko 已提交
424 425
.
.SH "SEE ALSO"
426
git(1), git\-clone(1), git\-remote(1), git\-init(1), \fIhttp://github\.com\fR, \fIhttp://github\.com/defunkt/hub\fR