2012-03-20 18:16:31 +04:00
|
|
|
git + hub = github
|
|
|
|
==================
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
hub is a command line tool that wraps `git` in order to extend it with extra
|
|
|
|
features and commands that make working with GitHub easier.
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
~~~ sh
|
|
|
|
$ hub clone rtomayko/tilt
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
# expands to:
|
|
|
|
$ git clone git://github.com/rtomayko/tilt.git
|
|
|
|
~~~
|
2009-12-08 11:34:29 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
hub is best aliased as `git`, so you can type `$ git <command>` in the shell and
|
|
|
|
get all the usual `hub` features. See "Aliasing" below.
|
2010-03-06 05:05:44 +03:00
|
|
|
|
2009-12-08 11:34:29 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
Installation
|
|
|
|
------------
|
2009-12-08 11:34:29 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
Dependencies:
|
2009-12-08 11:34:29 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
* **git 1.7.3** or newer
|
2010-03-06 05:05:44 +03:00
|
|
|
|
2014-10-20 23:02:58 +04:00
|
|
|
### 2.x
|
|
|
|
|
|
|
|
Starting from 2.2.0, `hub` is [powered by Go](https://github.com/github/hub/issues/475).
|
|
|
|
It should maintain a high backward compatibility with 1.x. Note that 2.x is in preview.
|
|
|
|
|
|
|
|
#### Standalone
|
|
|
|
|
|
|
|
`hub` 2.x can be easily installed as an executable. Download the latest
|
|
|
|
[complied binaries](https://github.com/github/hub/releases) and put it anywhere in your executable path.
|
|
|
|
|
|
|
|
#### Source
|
|
|
|
|
|
|
|
To install `hub` 2.x from source, you need to have a [Go development environment](http://golang.org/doc/install),
|
|
|
|
version 1.1 or better:
|
|
|
|
|
|
|
|
~~~ sh
|
|
|
|
$ git clone https://github.com/github/hub.git
|
|
|
|
$ cd hub
|
|
|
|
$ ./script/build
|
|
|
|
$ cp hub YOUR_BIN_PATH
|
|
|
|
~~~
|
|
|
|
|
|
|
|
### 1.x
|
|
|
|
|
|
|
|
#### Homebrew
|
2009-12-09 07:10:12 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
Installing on OS X is easiest with Homebrew:
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
~~~ sh
|
|
|
|
$ brew install hub
|
|
|
|
~~~
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2013-10-03 13:08:30 +04:00
|
|
|
Now you should be ready to roll:
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
~~~ sh
|
|
|
|
$ hub version
|
|
|
|
git version 1.7.6
|
|
|
|
hub version 1.8.3
|
|
|
|
~~~
|
2009-12-11 19:44:42 +03:00
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-09 04:40:45 +03:00
|
|
|
Aliasing
|
|
|
|
--------
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
Using hub feels best when it's aliased as `git`. This is not dangerous; your
|
|
|
|
_normal git commands will all work_. hub merely adds some sugar.
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2012-03-20 22:04:01 +04:00
|
|
|
`hub alias` displays instructions for the current shell. With the `-s` flag, it
|
|
|
|
outputs a script suitable for `eval`.
|
2009-12-09 07:08:36 +03:00
|
|
|
|
2012-03-20 22:04:01 +04:00
|
|
|
You should place this command in your `.bash_profile` or other startup script:
|
2009-12-09 07:08:36 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
~~~ sh
|
2012-03-20 22:04:01 +04:00
|
|
|
eval "$(hub alias -s)"
|
2012-03-20 18:16:31 +04:00
|
|
|
~~~
|
2009-12-08 12:12:53 +03:00
|
|
|
|
2012-03-20 23:08:12 +04:00
|
|
|
### Shell tab-completion
|
|
|
|
|
|
|
|
hub repository contains tab-completion scripts for bash and zsh. These scripts
|
|
|
|
complement existing completion scripts that ship with git.
|
|
|
|
|
2013-07-10 00:32:00 +04:00
|
|
|
* [hub bash completion](https://github.com/github/hub/blob/master/etc/hub.bash_completion.sh)
|
|
|
|
* [hub zsh completion](https://github.com/github/hub/blob/master/etc/hub.zsh_completion)
|
2012-03-20 23:08:12 +04:00
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-08 11:18:55 +03:00
|
|
|
Commands
|
2009-12-08 00:21:12 +03:00
|
|
|
--------
|
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
Assuming you've aliased hub as `git`, the following commands now have
|
2009-12-09 04:40:45 +03:00
|
|
|
superpowers:
|
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
### git clone
|
|
|
|
|
|
|
|
$ git clone schacon/ticgit
|
2009-12-08 11:29:29 +03:00
|
|
|
> git clone git://github.com/schacon/ticgit.git
|
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
$ git clone -p schacon/ticgit
|
2009-12-08 11:29:29 +03:00
|
|
|
> git clone git@github.com:schacon/ticgit.git
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-09 08:06:34 +03:00
|
|
|
$ git clone resque
|
2011-11-24 03:58:45 +04:00
|
|
|
> git clone git@github.com/YOUR_USER/resque.git
|
2009-12-09 08:06:34 +03:00
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
### git remote add
|
|
|
|
|
|
|
|
$ git remote add rtomayko
|
2009-12-08 11:29:29 +03:00
|
|
|
> git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git
|
|
|
|
|
2009-12-09 15:39:23 +03:00
|
|
|
$ git remote add -p rtomayko
|
2009-12-08 11:29:29 +03:00
|
|
|
> git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2010-02-13 12:42:07 +03:00
|
|
|
$ git remote add origin
|
|
|
|
> git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git
|
|
|
|
|
2010-04-18 04:37:21 +04:00
|
|
|
### 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
|
|
|
|
|
2010-04-18 06:37:32 +04:00
|
|
|
### 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
|
|
|
|
|
2011-10-20 17:40:40 +04:00
|
|
|
### git am, git apply
|
2011-10-19 19:41:10 +04:00
|
|
|
|
|
|
|
$ git am https://github.com/defunkt/hub/pull/55
|
2013-12-22 03:10:18 +04:00
|
|
|
[ downloads patch via API ]
|
2011-10-19 19:41:10 +04:00
|
|
|
> git am /tmp/55.patch
|
|
|
|
|
|
|
|
$ git am --ignore-whitespace https://github.com/davidbalbert/hub/commit/fdb9921
|
2013-12-22 03:10:18 +04:00
|
|
|
[ downloads patch via API ]
|
2011-10-19 19:41:10 +04:00
|
|
|
> git am --ignore-whitespace /tmp/fdb9921.patch
|
|
|
|
|
2011-10-20 17:40:40 +04:00
|
|
|
$ git apply https://gist.github.com/8da7fb575debd88c54cf
|
2013-12-22 03:10:18 +04:00
|
|
|
[ downloads patch via API ]
|
2011-10-20 17:40:40 +04:00
|
|
|
> git apply /tmp/gist-8da7fb575debd88c54cf.txt
|
|
|
|
|
2010-02-24 08:14:48 +03:00
|
|
|
### git fork
|
|
|
|
|
|
|
|
$ git fork
|
2011-10-19 17:13:09 +04:00
|
|
|
[ repo forked on GitHub ]
|
2010-04-07 21:11:52 +04:00
|
|
|
> git remote add -f YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git
|
2010-02-24 08:14:48 +03:00
|
|
|
|
2011-10-20 21:32:57 +04:00
|
|
|
### git pull-request
|
|
|
|
|
2011-10-21 05:07:30 +04:00
|
|
|
# while on a topic branch called "feature":
|
2011-10-24 03:12:26 +04:00
|
|
|
$ git pull-request
|
|
|
|
[ opens text editor to edit title & body for the request ]
|
2011-10-21 05:07:30 +04:00
|
|
|
[ opened pull request on GitHub for "YOUR_USER:feature" ]
|
2011-10-20 21:32:57 +04:00
|
|
|
|
2011-10-24 03:12:26 +04:00
|
|
|
# explicit title, pull base & head:
|
2013-05-11 23:58:07 +04:00
|
|
|
$ git pull-request -m "Implemented feature X" -b defunkt:master -h mislav:feature
|
2011-10-20 21:32:57 +04:00
|
|
|
|
2011-11-24 02:12:19 +04:00
|
|
|
### git checkout
|
|
|
|
|
2012-05-07 16:55:46 +04:00
|
|
|
$ git checkout https://github.com/defunkt/hub/pull/73
|
2014-03-12 18:51:47 +04:00
|
|
|
> git remote add -f -t feature mislav git://github.com/mislav/hub.git
|
2012-05-07 16:55:46 +04:00
|
|
|
> git checkout --track -B mislav-feature mislav/feature
|
2011-11-24 02:12:19 +04:00
|
|
|
|
2012-05-07 16:55:46 +04:00
|
|
|
$ git checkout https://github.com/defunkt/hub/pull/73 custom-branch-name
|
|
|
|
|
|
|
|
### git merge
|
|
|
|
|
|
|
|
$ git merge https://github.com/defunkt/hub/pull/73
|
|
|
|
> git fetch git://github.com/mislav/hub.git +refs/heads/feature:refs/remotes/mislav/feature
|
|
|
|
> git merge mislav/feature --no-ff -m 'Merge pull request #73 from mislav/feature...'
|
2011-11-24 02:12:19 +04:00
|
|
|
|
2010-05-13 00:31:52 +04:00
|
|
|
### git create
|
|
|
|
|
|
|
|
$ git create
|
2011-10-19 17:13:09 +04:00
|
|
|
[ repo created on GitHub ]
|
2010-05-13 00:31:52 +04:00
|
|
|
> git remote add origin git@github.com:YOUR_USER/CURRENT_REPO.git
|
|
|
|
|
2011-10-19 17:13:09 +04:00
|
|
|
# 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
|
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
### git init
|
|
|
|
|
2009-12-08 08:28:38 +03:00
|
|
|
$ git init -g
|
2009-12-08 11:29:29 +03:00
|
|
|
> git init
|
2009-12-09 08:06:34 +03:00
|
|
|
> git remote add origin git@github.com:YOUR_USER/REPO.git
|
2009-12-08 11:29:29 +03:00
|
|
|
|
2009-12-24 21:32:39 +03:00
|
|
|
### git push
|
|
|
|
|
|
|
|
$ git push origin,staging,qa bert_timeout
|
|
|
|
> git push origin bert_timeout
|
|
|
|
> git push staging bert_timeout
|
|
|
|
> git push qa bert_timeout
|
|
|
|
|
2010-01-24 01:15:27 +03:00
|
|
|
### git browse
|
|
|
|
|
2010-02-24 08:06:45 +03:00
|
|
|
$ git browse
|
2011-02-28 18:38:52 +03:00
|
|
|
> open https://github.com/YOUR_USER/CURRENT_REPO
|
2010-02-24 08:06:45 +03:00
|
|
|
|
2011-08-19 04:33:16 +04:00
|
|
|
$ git browse -- commit/SHA
|
|
|
|
> open https://github.com/YOUR_USER/CURRENT_REPO/commit/SHA
|
|
|
|
|
2010-04-18 00:26:12 +04:00
|
|
|
$ git browse -- issues
|
2011-02-28 18:38:52 +03:00
|
|
|
> open https://github.com/YOUR_USER/CURRENT_REPO/issues
|
2010-04-18 00:26:12 +04:00
|
|
|
|
2010-01-24 01:15:27 +03:00
|
|
|
$ git browse schacon/ticgit
|
2010-04-22 04:22:29 +04:00
|
|
|
> open https://github.com/schacon/ticgit
|
2010-01-24 01:15:27 +03:00
|
|
|
|
2011-08-19 04:33:16 +04:00
|
|
|
$ git browse schacon/ticgit commit/SHA
|
|
|
|
> open https://github.com/schacon/ticgit/commit/SHA
|
|
|
|
|
2010-01-24 01:15:27 +03:00
|
|
|
$ git browse resque
|
2010-12-28 16:01:48 +03:00
|
|
|
> open https://github.com/YOUR_USER/resque
|
2010-01-24 01:15:27 +03:00
|
|
|
|
2010-04-18 00:26:12 +04:00
|
|
|
$ git browse resque network
|
2010-12-28 16:01:48 +03:00
|
|
|
> open https://github.com/YOUR_USER/resque/network
|
2010-01-24 01:15:27 +03:00
|
|
|
|
2010-04-12 01:30:08 +04:00
|
|
|
### git compare
|
|
|
|
|
|
|
|
$ git compare refactor
|
2010-12-28 16:01:48 +03:00
|
|
|
> open https://github.com/CURRENT_REPO/compare/refactor
|
2010-04-12 01:30:08 +04:00
|
|
|
|
2011-06-12 20:03:04 +04:00
|
|
|
$ git compare 1.0..1.1
|
2010-12-28 16:01:48 +03:00
|
|
|
> open https://github.com/CURRENT_REPO/compare/1.0...1.1
|
2010-04-12 01:30:08 +04:00
|
|
|
|
|
|
|
$ git compare -u fix
|
2010-12-28 16:01:48 +03:00
|
|
|
> (https://github.com/CURRENT_REPO/compare/fix)
|
2010-04-12 01:30:08 +04:00
|
|
|
|
2010-04-22 04:22:29 +04:00
|
|
|
$ git compare other-user patch
|
2010-12-28 16:01:48 +03:00
|
|
|
> open https://github.com/other-user/REPO/compare/patch
|
2010-04-12 01:30:08 +04:00
|
|
|
|
2010-04-22 02:42:17 +04:00
|
|
|
### git submodule
|
2010-04-22 04:22:29 +04:00
|
|
|
|
2013-08-14 19:53:58 +04:00
|
|
|
$ git submodule add wycats/bundler vendor/bundler
|
2010-04-22 02:42:17 +04:00
|
|
|
> git submodule add git://github.com/wycats/bundler.git vendor/bundler
|
|
|
|
|
2013-08-14 19:53:58 +04:00
|
|
|
$ git submodule add -p wycats/bundler vendor/bundler
|
2010-04-22 02:42:17 +04:00
|
|
|
> git submodule add git@github.com:wycats/bundler.git vendor/bundler
|
|
|
|
|
2013-08-14 19:53:58 +04:00
|
|
|
$ git submodule add -b ryppl --name pip ryppl/pip vendor/pip
|
2013-01-19 22:57:57 +04:00
|
|
|
> git submodule add -b ryppl --name pip git://github.com/ryppl/pip.git vendor/pip
|
2010-04-22 02:42:17 +04:00
|
|
|
|
2013-01-20 22:43:28 +04:00
|
|
|
### git ci-status
|
|
|
|
|
2013-08-14 19:53:58 +04:00
|
|
|
$ git ci-status [commit]
|
2013-04-26 20:21:59 +04:00
|
|
|
> (prints CI state of commit and exits with appropriate code)
|
2013-01-20 22:43:28 +04:00
|
|
|
> One of: success (0), error (1), failure (1), pending (2), no status (3)
|
|
|
|
|
2010-04-22 02:42:17 +04:00
|
|
|
|
2009-12-08 11:29:29 +03:00
|
|
|
### git help
|
|
|
|
|
|
|
|
$ git help
|
|
|
|
> (improved git help)
|
2009-12-10 23:59:01 +03:00
|
|
|
$ git help hub
|
|
|
|
> (hub man page)
|
2009-12-08 00:21:12 +03:00
|
|
|
|
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
Configuration
|
|
|
|
-------------
|
|
|
|
|
2012-04-17 11:20:01 +04:00
|
|
|
### GitHub OAuth authentication
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2012-04-17 11:20:01 +04:00
|
|
|
Hub will prompt for GitHub username & password the first time it needs to access
|
|
|
|
the API and exchange it for an OAuth token, which it saves in "~/.config/hub".
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2012-05-05 02:37:53 +04:00
|
|
|
### HTTPS instead of git protocol
|
2009-12-24 21:55:07 +03:00
|
|
|
|
2011-10-25 18:55:35 +04:00
|
|
|
If you prefer using the HTTPS protocol for GitHub repositories instead of the git
|
|
|
|
protocol for read and ssh for write, you can set "hub.protocol" to "https".
|
2009-12-24 21:55:07 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
~~~ sh
|
|
|
|
# default behavior
|
|
|
|
$ git clone defunkt/repl
|
|
|
|
< git clone >
|
2009-12-24 21:55:07 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
# opt into HTTPS:
|
|
|
|
$ git config --global hub.protocol https
|
|
|
|
$ git clone defunkt/repl
|
|
|
|
< https clone >
|
|
|
|
~~~
|
2009-12-08 00:21:12 +03:00
|
|
|
|
|
|
|
|
2009-12-08 08:28:38 +03:00
|
|
|
Meta
|
|
|
|
----
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2013-07-10 00:32:00 +04:00
|
|
|
* Home: <https://github.com/github/hub>
|
|
|
|
* Bugs: <https://github.com/github/hub/issues>
|
|
|
|
* Authors: <https://github.com/github/hub/contributors>
|
2012-03-20 18:16:31 +04:00
|
|
|
|
|
|
|
### Prior art
|
2009-12-08 11:18:55 +03:00
|
|
|
|
2012-03-20 18:16:31 +04:00
|
|
|
These projects also aim to either improve git or make interacting with
|
|
|
|
GitHub simpler:
|
2009-12-08 11:18:55 +03:00
|
|
|
|
2014-07-30 10:00:01 +04:00
|
|
|
* [hub in Ruby](https://github.com/github/hub/tree/1.12-stable) (previous implementation)
|
2012-03-20 18:16:31 +04:00
|
|
|
* [eg](http://www.gnome.org/~newren/eg/)
|
|
|
|
* [github-gem](https://github.com/defunkt/github-gem)
|