提交 005198e3 编写于 作者: M Mislav Marohnić

ability to cherry-pick pull requests and commits with `hub am`

closes #63
上级 f4ac3b02
......@@ -215,6 +215,19 @@ module Hub
end
end
# $ hub 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
def am(args)
if url = args.find { |a| a =~ %r{^https?://github\.com/} }
idx = args.index(url)
url += '.patch' unless File.extname(url) == '.patch'
patch_file = File.join(ENV['TMPDIR'], File.basename(url))
args.before 'curl', ['-#LA', "hub #{Hub::Version}", url, '-o', patch_file]
args[idx] = patch_file
end
end
# $ hub init -g
# > git init
# > git remote add origin git@github.com:USER/REPO.git
......
......@@ -35,7 +35,11 @@ module Hub
# An array of all commands as strings.
def commands
args.commands.map do |cmd|
cmd.respond_to?(:join) ? cmd.join(' ') : cmd.to_s
if cmd.respond_to?(:join)
cmd.map { |c| c.index(' ') ? "'#{c}'" : c }.join(' ')
else
cmd.to_s
end
end
end
......
.\" generated with Ronn/v0.5
.\" http://github.com/rtomayko/ronn/
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "HUB" "1" "August 2010" "DEFUNKT" "Git Manual"
.TH "HUB" "1" "December 2010" "DEFUNKT" "Git Manual"
.
.SH "NAME"
\fBhub\fR \- git + hub = github
......@@ -16,7 +16,10 @@
\fBgit init \-g\fR \fIOPTIONS\fR
.
.br
\fBgit create\fR [\fB\-p\fR] [\fB\-d <DESCRIPTION>\fR] [\fB\-h <HOMEPAGE>\fR]: \fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
\fBgit create\fR [\fB\-p\fR] [\fB\-d <DESCRIPTION>\fR] [\fB\-h <HOMEPAGE>\fR]
.
.br
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
.
.br
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR]
......@@ -25,19 +28,22 @@
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
.
.br
\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,...]
\fBgit fetch\fR \fIUSER\-1\fR,[\fIUSER\-2\fR,\.\.\.]
.
.br
\fBgit cherry\-pick\fR \fIGITHUB\-REF\fR
.
.br
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,...,\fIREMOTE\-N\fR \fIREF\fR
\fBgit am\fR \fIGITHUB\-URL\fR
.
.br
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR \fIREF\fR
.
.br
\fBgit browse\fR [\fB\-p\fR] [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
.
.br
\fBgit compare\fR [\fB\-p\fR] [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR...]\fIEND\fR
\fBgit compare\fR [\fB\-p\fR] [\fB\-u\fR] [\fIUSER\fR] [\fISTART\fR\.\.\.]\fIEND\fR
.
.br
\fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
......@@ -46,98 +52,58 @@
\fBgit fork\fR [\fB\-\-no\-remote\fR]
.
.SH "DESCRIPTION"
\fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion. The
alias command displays information on configuring your environment:
\fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion\. The alias command displays information on configuring your environment:
.
.IP "\(bu" 4
\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:
\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:
.
.br
\fBeval $(hub alias \-s bash)\fR
.
.IP "\(bu" 4
\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.
\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\.
.
.IP "\(bu" 4
\fBgit create\fR [\fB\-p\fR] [\fB\-d <DESCRIPTION>\fR] [\fB\-h <HOMEPAGE>\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's
basename. With \fB\-p\fR, create a private repository. \fB\-d\fR and \fB\-h\fR
set the repository's description and homepage, respectively.
\fBgit create\fR [\fB\-p\fR] [\fB\-d <DESCRIPTION>\fR] [\fB\-h <HOMEPAGE>\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\'s basename\. With \fB\-p\fR, create a private repository\. \fB\-d\fR and \fB\-h\fR set the repository\'s description and homepage, respectively\.
.
.IP "\(bu" 4
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR:
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".
\fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR: 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"\.
.
.IP "\(bu" 4
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]:
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.
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]: 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\.
.
.IP "\(bu" 4
\fBgit remote set\-url\fR [\fB\-p\fR] \fIOPTIONS\fR \fIREMOTE\-NAME\fR \fIUSER\fR[/\fIREPOSITORY\fR]
.
.br
Sets the url of remote \fIREMOTE\-NAME\fR using the same rules as \fBgit remote add\fR.
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\.
.
.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.
\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\.
.
.IP "\(bu" 4
\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.
\fBgit am\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\. Similar to \fBcherry\-pick\fR, but doesn\'t add new remotes\.
.
.IP "\(bu" 4
\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.
\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\.
.
.IP "\(bu" 4
\fBgit browse\fR [\fB\-p\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. Use \fB\-p\fR to open a
page with https. 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").
\fBgit browse\fR [\fB\-p\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\. Use \fB\-p\fR to open a page with https\. 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")\.
.
.IP "\(bu" 4
\fBgit compare\fR [\fB\-p\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 \fISTART\fR is omitted, GitHub will
compare against the base branch (the default is "master").
\fBgit compare\fR [\fB\-p\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 \fISTART\fR is omitted, GitHub will compare against the base branch (the default is "master")\.
.
.IP "\(bu" 4
\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".
\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"\.
.
.IP "\(bu" 4
\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).
\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)\.
.
.IP "\(bu" 4
\fBgit help\fR:
Display enhanced git\-help(1).
\fBgit help\fR: Display enhanced git\-help(1)\.
.
.IP "" 0
.
......@@ -148,7 +114,7 @@ Use git\-config(1) to display the currently configured GitHub username:
.
.nf
$ git config \-\-global github.user
$ git config \-\-global github\.user
.
.fi
.
......@@ -161,31 +127,40 @@ Or, set the GitHub username and token with:
.
.nf
$ git config \-\-global github.user <username>
$ git config \-\-global github.token <token>
$ git config \-\-global github\.user <username>
$ git config \-\-global github\.token <token>
.
.fi
.
.IP "" 0
.
.P
See \fIhttp://github.com/guides/local\-github\-config\fR for more
information.
See \fIhttp://github\.com/guides/local\-github\-config\fR for more information\.
.
.P
You can also tell \fBhub\fR to use \fBhttp://\fR rather than \fBgit://\fR when
cloning:
You can also tell \fBhub\fR to use \fBhttp://\fR rather than \fBgit://\fR when cloning:
.
.IP "" 4
.
.nf
$ git config \-\-global \-\-bool hub.http\-clone true
$ git config \-\-global \-\-bool hub\.http\-clone true
.
.fi
.
.IP "" 0
.
.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
.
.SH "EXAMPLES"
.
.SS "git clone"
......@@ -193,16 +168,16 @@ $ git config \-\-global \-\-bool hub.http\-clone true
.nf
$ git clone schacon/ticgit
> git clone git://github.com/schacon/ticgit.git
> git clone git://github\.com/schacon/ticgit\.git
$ git clone \-p schacon/ticgit
> git clone git@github.com:schacon/ticgit.git
> git clone git@github\.com:schacon/ticgit\.git
$ git clone resque
> git clone git://github.com/YOUR_USER/resque.git
> git clone git://github\.com/YOUR_USER/resque\.git
$ git clone \-p resque
> git clone git@github.com:YOUR_USER/resque.git
> git clone git@github\.com:YOUR_USER/resque\.git
.
.fi
.
......@@ -211,13 +186,13 @@ $ git clone \-p resque
.nf
$ git remote add rtomayko
> git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git
> 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
> git remote add rtomayko git@github\.com:rtomayko/CURRENT_REPO\.git
$ git remote add origin
> git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git
> git remote add origin git://github\.com/YOUR_USER/CURRENT_REPO\.git
.
.fi
.
......@@ -226,12 +201,12 @@ $ git remote add origin
.nf
$ git fetch mislav
> git remote add mislav git://github.com/mislav/REPO.git
> 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 remote add mislav \.\.\.
> git remote add xoebus \.\.\.
> git fetch \-\-multiple mislav xoebus
.
.fi
......@@ -240,12 +215,12 @@ $ git fetch mislav,xoebus
.
.nf
$ git cherry\-pick http://github.com/mislav/REPO/commit/SHA
> git remote add \-f mislav git://github.com/mislav/REPO.git
$ 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 remote add \-f mislav git://github\.com/mislav/CURRENT_REPO\.git
> git cherry\-pick SHA
$ git cherry\-pick mislav@SHA
......@@ -254,13 +229,27 @@ $ git cherry\-pick mislav@SHA
.
.fi
.
.SS "git am"
.
.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
.
.fi
.
.SS "git fork"
.
.nf
$ git fork
... hardcore forking action ...
> git remote add YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git
\.\.\. hardcore forking action \.\.\.
> git remote add YOUR_USER git@github\.com:YOUR_USER/CURRENT_REPO\.git
.
.fi
.
......@@ -270,7 +259,7 @@ $ git fork
$ git init \-g
> git init
> git remote add origin git@github.com:YOUR_USER/REPO.git
> git remote add origin git@github\.com:YOUR_USER/REPO\.git
.
.fi
.
......@@ -279,8 +268,8 @@ $ git init \-g
.nf
$ git create
... hardcore creating action ...
> git remote add origin git@github.com:YOUR_USER/CURRENT_REPO.git
\.\.\. hardcore creating action \.\.\.
> git remote add origin git@github\.com:YOUR_USER/CURRENT_REPO\.git
.
.fi
.
......@@ -300,25 +289,25 @@ $ git push origin,staging,qa bert_timeout
.nf
$ git browse
> open http://github.com/CURRENT_REPO
> open http://github\.com/CURRENT_REPO
$ git browse \-\- issues
> open http://github.com/CURRENT_REPO/issues
> open http://github\.com/CURRENT_REPO/issues
$ git browse schacon/ticgit
> open http://github.com/schacon/ticgit
> open http://github\.com/schacon/ticgit
$ git browse \-p schacon/ticgit
> open https://github.com/schacon/ticgit
> open https://github\.com/schacon/ticgit
$ git browse resque
> open http://github.com/YOUR_USER/resque
> open http://github\.com/YOUR_USER/resque
$ git browse resque network
> open http://github.com/YOUR_USER/resque/network
> open http://github\.com/YOUR_USER/resque/network
$ git browse \-p resque
> open https://github.com/YOUR_USER/resque
> open https://github\.com/YOUR_USER/resque
.
.fi
.
......@@ -327,16 +316,16 @@ $ git browse \-p resque
.nf
$ git compare refactor
> open http://github.com/CURRENT_REPO/compare/refactor
> open http://github\.com/CURRENT_REPO/compare/refactor
$ git compare 1.0...1.1
> open http://github.com/CURRENT_REPO/compare/1.0...1.1
$ git compare 1\.0\.\.\.1\.1
> open http://github\.com/CURRENT_REPO/compare/1\.0\.\.\.1\.1
$ git compare \-u fix
> (http://github.com/CURRENT_REPO/compare/fix)
> (http://github\.com/CURRENT_REPO/compare/fix)
$ git compare other\-user patch
> open http://github.com/other\-user/REPO/compare/patch
> open http://github\.com/other\-user/REPO/compare/patch
.
.fi
.
......@@ -352,10 +341,10 @@ $ git help hub
.fi
.
.SH "BUGS"
\fIhttp://github.com/defunkt/hub/issues\fR
\fIhttp://github\.com/defunkt/hub/issues\fR
.
.SH "AUTHOR"
Chris Wanstrath :: chris@ozmm.org :: @defunkt
.SH "AUTHORS"
\fIhttps://github\.com/defunkt/hub/contributors\fR
.
.SH "SEE ALSO"
git(1), git\-clone(1), git\-remote(1), git\-init(1), \fIhttp://github.com\fR, \fIhttp://github.com/defunkt/hub\fR
git(1), git\-clone(1), git\-remote(1), git\-init(1), \fIhttp://github\.com\fR, \fIhttp://github\.com/defunkt/hub\fR
......@@ -2,147 +2,77 @@
<html>
<head>
<meta http-equiv='content-type' value='text/html;charset=utf8'>
<meta name='generator' value='Ronn/v0.5 (http://github.com/rtomayko/ronn)'>
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
<title>hub(1) - git + hub = github</title>
<style type='text/css' media='all'>
/* STRUCTURE, INDENT, MARGINS */
body { margin:0}
#man { max-width:92ex; padding:0 2ex 1ex 2ex}
#man p, #man pre,
#man ul, #man ol, #man dl { margin:0 0 20px 0}
#man h2 { margin:10px 0 0 0}
#man > p, #man > pre,
#man > ul, #man > ol, #man > dl { margin-left:8ex}
#man h3 { margin:0 0 0 4ex}
#man dt { margin:0; clear:left}
#man dt.flush { float:left; width:8ex}
#man dd { margin:0 0 0 9ex}
#man h1, #man h2, #man h3, #man h4 { clear:left}
#man pre { margin-bottom:20px}
#man pre+h2, #man pre+h3 { margin-top:22px}
#man h2+pre, #man h3+pre { margin-top:5px}
#man img { display:block;margin:auto}
#man h1.man-title { display:none}
/* FONTS */
#man, #man code, #man pre,
#man tt, #man kbd, #man samp,
#man h3, #man h4 {
font-family:monospace;
font-size:14px;
line-height:1.42857142857143;
}
#man h2, #man ol.man, #man .man-navigation a {
font-size:16px;
line-height:1.25
}
#man h1 {
font-size:20px;
line-height:2;
}
/* TEXT STYLES */
#man {
text-align:justify;
background:#fff;
}
#man, #man code, #man pre, #man pre code,
#man tt, #man kbd, #man samp { color:#131211}
#man h1, #man h2, #man h3, #man h4 { color:#030201}
#man ol.man, #man ol.man li { color:#636261}
#man code, #man strong, #man b {
font-weight:bold;
color:#131211;
}
#man em, #man var, #man u {
font-style:italic;
color:#434241;
text-decoration:none;
}
#man pre {
background:#edeceb;
padding:5px 1ex;
border-left:1ex solid #ddd;
}
#man pre code {
font-weight:normal;
background:inherit;
}
/* DOCUMENT HEADER AND FOOTER AREAS */
#man ol.man, #man ol.man li {
margin:3px 0 10px 0;
padding:0;
float:left;
width:33%;
list-style-type:none;
text-transform:uppercase;
color:#999;
letter-spacing:1px;
}
#man ol.man { width:100%}
#man ol.man li.tl { text-align:left}
#man ol.man li.tc { text-align:center; letter-spacing:4px}
#man ol.man li.tr { text-align:right; float:right}
/* SECTION TOC NAVIGATION */
#man div.man-navigation {
position:fixed;
top:0;
left:106ex;
height:100%;
width:100%;
padding:1ex 0 0 2ex;
border-left:0.25ex solid #DCDCDC;
background-color: #F5F5F5;
}
#man div.man-navigation a { display:block; margin-bottom:1.5ex}
</style>
<style type='text/css' media='print'>
#man { max-width:none}
#man div.man-navigation { display:none}
#man a[href]:not([href^="#"]):not([data-bare-link]):after {
content:" " attr(href);
}
/* style: man */
body#manpage {margin:0}
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
.mp h2 {margin:10px 0 0 0}
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
.mp h3 {margin:0 0 0 4ex}
.mp dt {margin:0;clear:left}
.mp dt.flush {float:left;width:8ex}
.mp dd {margin:0 0 0 9ex}
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
.mp pre {margin-bottom:20px}
.mp pre+h2,.mp pre+h3 {margin-top:22px}
.mp h2+pre,.mp h3+pre {margin-top:5px}
.mp img {display:block;margin:auto}
.mp h1.man-title {display:none}
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
.mp h2 {font-size:16px;line-height:1.25}
.mp h1 {font-size:20px;line-height:2}
.mp {text-align:justify;background:#fff}
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
.mp u {text-decoration:underline}
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
.mp b.man-ref {font-weight:normal;color:#434241}
.mp pre {padding:0 4ex}
.mp pre code {font-weight:normal;color:#434241}
.mp h2+pre,h3+pre {padding-left:0}
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
ol.man-decor {width:100%}
ol.man-decor li.tl {text-align:left}
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
ol.man-decor li.tr {text-align:right;float:right}
</style>
</head>
<!--
The following styles are deprecated and will be removed at some point:
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
.man-navigation should be used instead.
-->
<body id='manpage'>
<div id='man'>
<div class='mp' id='man'>
<div class='man-navigation'>
<div class='man-navigation' style='display:none'>
<a href="#NAME">NAME</a>
<a href="#SYNOPSIS">SYNOPSIS</a>
<a href="#DESCRIPTION">DESCRIPTION</a>
<a href="#CONFIGURATION">CONFIGURATION</a>
<a href="#EXAMPLES">EXAMPLES</a>
<a href="#BUGS">BUGS</a>
<a href="#AUTHOR">AUTHOR</a>
<a href="#AUTHORS">AUTHORS</a>
<a href="#SEE-ALSO">SEE ALSO</a>
</div>
<h1 class='man-title'>hub(1)</h1>
<ol class='man head'>
<ol class='man-decor man-head man head'>
<li class='tl'>hub(1)</li>
<li class='tc'>Git Manual</li>
<li class='tr'>hub(1)</li>
</ol>
<h2 id='NAME'>NAME</h2>
<p><code>hub</code> - git + hub = github</p>
<h2 id="NAME">NAME</h2>
<p class="man-name">
<code>hub</code> - <span class="man-whatis">git + hub = github</span>
</p>
<h2 id="SYNOPSIS">SYNOPSIS</h2>
......@@ -150,12 +80,13 @@
<code>hub alias</code> [<code>-s</code>] <var>SHELL</var></p>
<p><code>git init -g</code> <var>OPTIONS</var><br />
<code>git create</code> [<code>-p</code>] [<code>-d &lt;DESCRIPTION></code>] [<code>-h &lt;HOMEPAGE></code>]:
<code>git create</code> [<code>-p</code>] [<code>-d &lt;DESCRIPTION></code>] [<code>-h &lt;HOMEPAGE></code>]<br />
<code>git clone</code> [<code>-p</code>] <var>OPTIONS</var> [<var>USER</var>/]<var>REPOSITORY</var> <var>DIRECTORY</var><br />
<code>git remote add</code> [<code>-p</code>] <var>OPTIONS</var> <var>USER</var>[/<var>REPOSITORY</var>]<br />
<code>git remote set-url</code> [<code>-p</code>] <var>OPTIONS</var> <var>REMOTE-NAME</var> <var>USER</var>[/<var>REPOSITORY</var>]<br />
<code>git fetch</code> <var>USER-1</var>,[<var>USER-2</var>,...]<br />
<code>git cherry-pick</code> <var>GITHUB-REF</var><br />
<code>git am</code> <var>GITHUB-URL</var><br />
<code>git push</code> <var>REMOTE-1</var>,<var>REMOTE-2</var>,...,<var>REMOTE-N</var> <var>REF</var><br />
<code>git browse</code> [<code>-p</code>] [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>] [SUBPAGE]<br />
<code>git compare</code> [<code>-p</code>] [<code>-u</code>] [<var>USER</var>] [<var>START</var>...]<var>END</var><br />
......@@ -174,7 +105,7 @@ Writes shell aliasing code for <var>SHELL</var> (<code>bash</code>, <code>sh</co
this command can be evaluated directly within the shell:<br />
<code>eval $(hub alias -s bash)</code></p></li>
<li><p><code>git init</code> <code>-g</code> <var>OPTIONS</var>:
Create a git repository as with git-init(1) and add remote <code>origin</code> at
Create a git repository as with <span class="man-ref">git-init<span class="s">(1)</span></span> and add remote <code>origin</code> at
"git@github.com:<var>USER</var>/<var>REPOSITORY</var>.git"; <var>USER</var> is your GitHub username and
<var>REPOSITORY</var> is the current working directory's basename.</p></li>
<li><p><code>git create</code> [<code>-p</code>] [<code>-d &lt;DESCRIPTION></code>] [<code>-h &lt;HOMEPAGE></code>]:
......@@ -186,12 +117,12 @@ basename. With <code>-p</code>, create a private repository. <code>-d</code> and
set the repository's description and homepage, respectively.</p></li>
<li><p><code>git clone</code> [<code>-p</code>] <var>OPTIONS</var> [<var>USER</var><code>/</code>]<var>REPOSITORY</var> <var>DIRECTORY</var>:
Clone repository "git://github.com/<var>USER</var>/<var>REPOSITORY</var>.git" into
<var>DIRECTORY</var> as with git-clone(1). When <var>USER</var>/ is omitted, assumes
<var>DIRECTORY</var> as with <span class="man-ref">git-clone<span class="s">(1)</span></span>. When <var>USER</var>/ is omitted, assumes
your GitHub login. With <code>-p</code>, use private remote
"git@github.com:<var>USER</var>/<var>REPOSITORY</var>.git".</p></li>
<li><p><code>git remote add</code> [<code>-p</code>] <var>OPTIONS</var> <var>USER</var>[<code>/</code><var>REPOSITORY</var>]:
Add remote "git://github.com/<var>USER</var>/<var>REPOSITORY</var>.git" as with
git-remote(1). When /<var>REPOSITORY</var> is omitted, the basename of the
<span class="man-ref">git-remote<span class="s">(1)</span></span>. When /<var>REPOSITORY</var> is omitted, the basename of the
current working directory is used. With <code>-p</code>, use private remote
"git@github.com:<var>USER</var>/<var>REPOSITORY</var>.git". If <var>USER</var> is "origin"
then uses your GitHub login.</p></li>
......@@ -206,6 +137,10 @@ Cherry-pick a commit from a fork using either full URL to the commit
or GitHub-flavored Markdown notation, which is <code>user@sha</code>. If the remote
doesn't yet exist, it will be added. A <code>git fetch &lt;user></code> is issued
prior to the cherry-pick attempt.</p></li>
<li><p><code>git am</code> <var>GITHUB-URL</var>:
Downloads the patch file for the pull request or commit at the URL and
applies that patch from disk with <code>git am</code>. Similar to <code>cherry-pick</code>, but
doesn't add new remotes.</p></li>
<li><p><code>git push</code> <var>REMOTE-1</var>,<var>REMOTE-2</var>,...,<var>REMOTE-N</var> <var>REF</var>:
Push <var>REF</var> to each of <var>REMOTE-1</var> through <var>REMOTE-N</var> by executing
multiple <code>git push</code> commands.</p></li>
......@@ -223,7 +158,7 @@ the range of history to compare. If <var>START</var> is omitted, GitHub will
compare against the base branch (the default is "master").</p></li>
<li><p><code>git submodule add</code> [<code>-p</code>] <var>OPTIONS</var> [<var>USER</var>/]<var>REPOSITORY</var> <var>DIRECTORY</var>:
Submodule repository "git://github.com/<var>USER</var>/<var>REPOSITORY</var>.git" into
<var>DIRECTORY</var> as with git-submodule(1). When <var>USER</var>/ is omitted, assumes
<var>DIRECTORY</var> as with <span class="man-ref">git-submodule<span class="s">(1)</span></span>. When <var>USER</var>/ is omitted, assumes
your GitHub login. With <code>-p</code>, use private remote
"git@github.com:<var>USER</var>/<var>REPOSITORY</var>.git".</p></li>
<li><p><code>git fork</code> [<code>--no-remote</code>]:
......@@ -231,13 +166,13 @@ Forks the original project (referenced by "origin" remote) on GitHub and
adds a new remote for it under your username. Requires <code>github.token</code> to
be set (see CONFIGURATION).</p></li>
<li><p><code>git help</code>:
Display enhanced git-help(1).</p></li>
Display enhanced <span class="man-ref">git-help<span class="s">(1)</span></span>.</p></li>
</ul>
<h2 id="CONFIGURATION">CONFIGURATION</h2>
<p>Use git-config(1) to display the currently configured GitHub username:</p>
<p>Use <span class="man-ref">git-config<span class="s">(1)</span></span> to display the currently configured GitHub username:</p>
<pre><code>$ git config --global github.user
</code></pre>
......@@ -257,6 +192,21 @@ cloning:</p>
<pre><code>$ git config --global --bool hub.http-clone true
</code></pre>
<p>Want to use environment variables instead of a local gitconfig for
authentication?</p>
<ul>
<li><code>GITHUB_USER</code> - If set, this will be used instead of the <code>github.user</code> config
<pre><code> value to determine your GitHub username.
</code></pre></li>
<li><code>GITHUB_TOKEN</code> - If set, this will be used instead of the <code>github.token</code>
<pre><code> config value to determine your GitHub API token.
</code></pre></li>
</ul>
<h2 id="EXAMPLES">EXAMPLES</h2>
<h3 id="git-clone">git clone</h3>
......@@ -313,6 +263,17 @@ $ git cherry-pick mislav@SHA
&gt; git cherry-pick SHA
</code></pre>
<h3 id="git-am">git am</h3>
<pre><code>$ git am https://github.com/defunkt/hub/pull/55
&gt; curl https://github.com/defunkt/hub/pull/55.patch -o /tmp/55.patch
&gt; git am /tmp/55.patch
$ git am --ignore-whitespace https://github.com/davidbalbert/hub/commit/fdb9921
&gt; curl https://github.com/davidbalbert/hub/commit/fdb9921.patch -o /tmp/fdb9921.patch
&gt; git am --ignore-whitespace /tmp/fdb9921.patch
</code></pre>
<h3 id="git-fork">git fork</h3>
<pre><code>$ git fork
......@@ -393,20 +354,20 @@ $ git help hub
<p><a href="http://github.com/defunkt/hub/issues" data-bare-link="true">http://github.com/defunkt/hub/issues</a></p>
<h2 id="AUTHOR">AUTHOR</h2>
<h2 id="AUTHORS">AUTHORS</h2>
<p>Chris Wanstrath :: chris@ozmm.org :: @defunkt</p>
<p><a href="https://github.com/defunkt/hub/contributors" data-bare-link="true">https://github.com/defunkt/hub/contributors</a></p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
<p>git(1), git-clone(1), git-remote(1), git-init(1),
<p><span class="man-ref">git<span class="s">(1)</span></span>, <span class="man-ref">git-clone<span class="s">(1)</span></span>, <span class="man-ref">git-remote<span class="s">(1)</span></span>, <span class="man-ref">git-init<span class="s">(1)</span></span>,
<a href="http://github.com" data-bare-link="true">http://github.com</a>,
<a href="http://github.com/defunkt/hub" data-bare-link="true">http://github.com/defunkt/hub</a></p>
<ol class='man foot'>
<ol class='man-decor man-foot man foot'>
<li class='tl'>DEFUNKT</li>
<li class='tc'>August 2010</li>
<li class='tc'>December 2010</li>
<li class='tr'>hub(1)</li>
</ol>
......
......@@ -7,12 +7,13 @@ hub(1) -- git + hub = github
`hub alias` [`-s`] <SHELL>
`git init -g` <OPTIONS>
`git create` [`-p`] [`-d <DESCRIPTION>`] [`-h <HOMEPAGE>`]:
`git create` [`-p`] [`-d <DESCRIPTION>`] [`-h <HOMEPAGE>`]
`git clone` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>
`git remote add` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>]
`git remote set-url` [`-p`] <OPTIONS> <REMOTE-NAME> <USER>[/<REPOSITORY>]
`git fetch` <USER-1>,[<USER-2>,...]
`git cherry-pick` <GITHUB-REF>
`git am` <GITHUB-URL>
`git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> <REF>
`git browse` [`-p`] [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]
`git compare` [`-p`] [`-u`] [<USER>] [<START>...]<END>
......@@ -70,6 +71,11 @@ alias command displays information on configuring your environment:
doesn't yet exist, it will be added. A `git fetch <user>` is issued
prior to the cherry-pick attempt.
* `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.
* `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> <REF>:
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
multiple `git push` commands.
......@@ -181,6 +187,16 @@ authentication?
> git fetch mislav
> git cherry-pick SHA
### 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
### git fork
$ git fork
......
......@@ -347,6 +347,28 @@ class HubTest < Test::Unit::TestCase
"cherry-pick xoebus@a319d88"
end
def test_am_untouched
assert_forwarded "am some.patch"
end
def test_am_pull_request
with_tmpdir('/tmp/') do
assert_commands "curl -#LA 'hub #{Hub::Version}' https://github.com/defunkt/hub/pull/55.patch -o /tmp/55.patch",
"git am --signoff /tmp/55.patch -p2",
"am --signoff https://github.com/defunkt/hub/pull/55 -p2"
end
end
def test_am_commit_url
with_tmpdir('/tmp/') do
url = 'https://github.com/davidbalbert/hub/commit/fdb9921'
assert_commands "curl -#LA 'hub #{Hub::Version}' #{url}.patch -o /tmp/fdb9921.patch",
"git am --signoff /tmp/fdb9921.patch -p2",
"am --signoff #{url} -p2"
end
end
def test_init
assert_commands "git init", "git remote add origin git@github.com:tpw/hub.git", "init -g"
end
......@@ -759,6 +781,13 @@ config
ENV['BROWSER'] = browser
end
def with_tmpdir(value)
dir, ENV['TMPDIR'] = ENV['TMPDIR'], value
yield
ensure
ENV['TMPDIR'] = dir
end
def assert_browser(browser)
assert_command "browse", "#{browser} http://github.com/defunkt/hub"
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册