2009-12-08 08:28:38 +03:00
|
|
|
hub: git + hub = github
|
|
|
|
=======================
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-09 07:05:17 +03:00
|
|
|
`hub` is a command line utility which adds GitHub knowledge to `git`.
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2011-04-27 01:30:31 +04:00
|
|
|
It can be used on its own or as a `git` wrapper.
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-08 12:12:32 +03:00
|
|
|
Normal:
|
2009-12-08 11:34:29 +03:00
|
|
|
|
|
|
|
$ hub clone rtomayko/tilt
|
2010-03-06 05:05:44 +03:00
|
|
|
|
2010-02-22 08:53:42 +03:00
|
|
|
Expands to:
|
|
|
|
$ git clone git://github.com/rtomayko/tilt.git
|
2009-12-08 11:34:29 +03:00
|
|
|
|
2009-12-09 07:05:17 +03:00
|
|
|
Wrapping `git`:
|
2009-12-08 11:34:29 +03:00
|
|
|
|
|
|
|
$ git clone rack/rack
|
|
|
|
|
2010-03-06 05:05:44 +03:00
|
|
|
Expands to:
|
|
|
|
$ git clone git://github.com/rack/rack.git
|
|
|
|
|
2009-12-10 13:05:30 +03:00
|
|
|
hub requires you have `git` installed and in your `$PATH`. It also
|
2009-12-09 08:14:05 +03:00
|
|
|
requires Ruby 1.8.6+ or Ruby 1.9.1+. No other libraries necessary.
|
2009-12-09 07:10:12 +03:00
|
|
|
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-08 08:28:38 +03:00
|
|
|
Install
|
2009-12-08 00:21:12 +03:00
|
|
|
-------
|
|
|
|
|
2009-12-09 04:40:45 +03:00
|
|
|
### Standalone
|
|
|
|
|
2009-12-09 07:10:12 +03:00
|
|
|
`hub` is most easily installed as a standalone script:
|
2009-12-08 12:12:32 +03:00
|
|
|
|
2011-03-22 01:49:17 +03:00
|
|
|
curl http://defunkt.io/hub/standalone -sLo ~/bin/hub &&
|
2010-01-24 01:09:55 +03:00
|
|
|
chmod 755 ~/bin/hub
|
2009-12-08 12:12:32 +03:00
|
|
|
|
2009-12-10 13:05:30 +03:00
|
|
|
Assuming `~/bin/` is in your `$PATH`, you're ready to roll:
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2009-12-09 07:05:17 +03:00
|
|
|
$ hub version
|
2010-04-18 01:21:56 +04:00
|
|
|
git version 1.7.0.4
|
|
|
|
hub version 1.1.0
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2009-12-11 19:44:42 +03:00
|
|
|
### Homebrew
|
|
|
|
|
2010-04-18 01:21:56 +04:00
|
|
|
$ brew install hub
|
|
|
|
$ which hub
|
|
|
|
/usr/local/bin/hub
|
|
|
|
$ hub version
|
|
|
|
...
|
2009-12-11 19:44:42 +03:00
|
|
|
|
2009-12-10 13:14:32 +03:00
|
|
|
### RubyGems
|
2009-12-09 08:28:15 +03:00
|
|
|
|
2009-12-10 13:14:32 +03:00
|
|
|
Though not recommended, `hub` can also be installed as a RubyGem:
|
2009-12-09 08:28:15 +03:00
|
|
|
|
2011-03-24 22:37:03 +03:00
|
|
|
$ gem install hub
|
2009-12-09 08:28:15 +03:00
|
|
|
|
2010-04-18 01:21:56 +04:00
|
|
|
(It's not recommended for casual use because of the RubyGems startup
|
|
|
|
time. See [this gist][speed] for information.)
|
2010-01-24 01:10:03 +03:00
|
|
|
|
2010-01-24 01:19:50 +03:00
|
|
|
### Standalone via RubyGems
|
|
|
|
|
2011-03-24 22:37:03 +03:00
|
|
|
$ gem install hub
|
2010-01-24 01:19:50 +03:00
|
|
|
$ hub hub standalone > ~/bin/hub && chmod 755 ~/bin/hub
|
2010-04-18 01:21:56 +04:00
|
|
|
|
|
|
|
This installs a standalone version which doesn't require RubyGems to
|
|
|
|
run.
|
2010-01-24 01:19:50 +03:00
|
|
|
|
2009-12-09 04:40:45 +03:00
|
|
|
### Source
|
|
|
|
|
2009-12-09 04:34:37 +03:00
|
|
|
You can also install from source:
|
2009-12-08 00:21:12 +03:00
|
|
|
|
|
|
|
$ git clone git://github.com/defunkt/hub.git
|
|
|
|
$ cd hub
|
2009-12-11 19:44:42 +03:00
|
|
|
$ rake install prefix=/usr/local
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2011-03-20 23:06:24 +03:00
|
|
|
### Help! It's Slow!
|
|
|
|
|
|
|
|
Is your prompt slow? It may be hub.
|
|
|
|
|
|
|
|
1. Check that it's **not** installed using RubyGems.
|
|
|
|
2. Check that RUBYOPT isn't loading anything shady:
|
|
|
|
|
2011-03-22 21:26:40 +03:00
|
|
|
$ echo $RUBYOPT
|
2011-03-20 23:06:24 +03:00
|
|
|
|
|
|
|
3. Check that your system Ruby is speedy:
|
|
|
|
|
2011-03-22 21:26:40 +03:00
|
|
|
$ time /usr/bin/env ruby -e0
|
2011-03-20 23:06:24 +03:00
|
|
|
|
|
|
|
If #3 is slow, it may be your [GC settings][gc].
|
|
|
|
|
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
|
|
|
|
2010-04-22 04:22:29 +04:00
|
|
|
`hub` works best when it wraps `git`. This is not dangerous - your
|
2009-12-09 07:08:36 +03:00
|
|
|
normal git commands should all work. hub merely adds some sugar.
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-09 07:08:36 +03:00
|
|
|
Typing `hub alias <shell>` will display alias instructions for
|
|
|
|
your shell. `hub alias` alone will show the known shells.
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-09 07:08:36 +03:00
|
|
|
For example:
|
|
|
|
|
|
|
|
$ hub alias bash
|
|
|
|
Run this in your shell to start using `hub` as `git`:
|
|
|
|
alias git=hub
|
|
|
|
|
|
|
|
You should place this command in your `.bash_profile` or other startup
|
2009-12-09 07:31:04 +03:00
|
|
|
script to ensure runs on login.
|
2009-12-09 07:08:36 +03:00
|
|
|
|
|
|
|
The alias command can also be eval'd directly using the `-s` flag:
|
|
|
|
|
|
|
|
$ eval `hub alias -s bash`
|
2009-12-08 12:12:53 +03: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
|
|
|
--------
|
|
|
|
|
2009-12-09 07:08:36 +03:00
|
|
|
Assuming you've aliased `hub` to `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
|
|
|
|
> git clone git://github.com/YOUR_USER/resque.git
|
|
|
|
|
|
|
|
$ git clone -p resque
|
|
|
|
> git clone git@github.com:YOUR_USER/resque.git
|
|
|
|
|
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
|
|
|
|
|
2010-02-24 08:14:48 +03:00
|
|
|
### git fork
|
|
|
|
|
|
|
|
$ git fork
|
|
|
|
... hardcore forking action ...
|
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
|
|
|
|
2010-04-07 21:11:52 +04:00
|
|
|
Forks the original repo on GitHub and adds the new remote under your
|
|
|
|
username. It requires your GitHub token to be present; see "GitHub
|
|
|
|
login" below for details.
|
2010-02-24 08:14:48 +03:00
|
|
|
|
2010-05-13 00:31:52 +04:00
|
|
|
### git create
|
|
|
|
|
|
|
|
$ git create
|
|
|
|
... hardcore creating action ...
|
|
|
|
> git remote add origin git@github.com:YOUR_USER/CURRENT_REPO.git
|
|
|
|
|
|
|
|
Creates a new public github repository and adds the remote `origin` at
|
|
|
|
"git@github.com:<USER>/<REPOSITORY>.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
|
|
|
|
2010-04-22 02:42:17 +04:00
|
|
|
$ 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
|
|
|
|
|
2010-04-22 04:22:29 +04:00
|
|
|
$ hub submodule add -b ryppl ryppl/pip vendor/pip
|
2010-04-22 02:42:17 +04:00
|
|
|
> git submodule add -b ryppl git://github.com/ryppl/pip.git vendor/pip
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2009-12-09 04:40:45 +03:00
|
|
|
GitHub Login
|
|
|
|
------------
|
|
|
|
|
|
|
|
To get the most out of `hub`, you'll want to ensure your GitHub login
|
2010-11-22 23:58:11 +03:00
|
|
|
is stored locally in your Git config or environment variables.
|
2009-12-09 04:40:45 +03:00
|
|
|
|
|
|
|
To test it run this:
|
|
|
|
|
|
|
|
$ git config --global github.user
|
|
|
|
|
|
|
|
If you see nothing, you need to set the config setting:
|
|
|
|
|
2009-12-09 08:14:05 +03:00
|
|
|
$ git config --global github.user YOUR_USER
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2010-02-24 08:14:48 +03:00
|
|
|
For commands that require write access to GitHub (such as `fork`), you'll want to
|
|
|
|
setup "github.token" as well. See [local GitHub config guide][2] for more information.
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2010-11-22 23:58:11 +03:00
|
|
|
Want to use environment variables instead of a local gitconfig?
|
|
|
|
|
|
|
|
* `GITHUB_USER` - If set, this will be used instead of the `github.user` config
|
|
|
|
value to determine your GitHub username.
|
|
|
|
* `GITHUB_TOKEN` - If set, this will be used instead of the `github.token` config
|
|
|
|
value to determine your GitHub API token.
|
2009-12-09 04:40:45 +03:00
|
|
|
|
2009-12-24 21:55:07 +03:00
|
|
|
Configuration
|
|
|
|
-------------
|
|
|
|
|
|
|
|
If you prefer `http://` clones to `git://` clones, you can set the
|
2010-04-17 21:00:05 +04:00
|
|
|
`hub.http-clone` option to true using `git-config`.
|
2009-12-24 21:55:07 +03:00
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
$ git clone defunkt/repl
|
|
|
|
< git clone >
|
2010-04-17 21:00:05 +04:00
|
|
|
$ git config --global --bool hub.http-clone true
|
2009-12-24 21:55:07 +03:00
|
|
|
$ git clone defunkt/repl
|
|
|
|
< http clone >
|
|
|
|
|
|
|
|
Or you can enter this manually into your `~/.gitconfig` file:
|
|
|
|
|
|
|
|
$ cat ~/.gitconfig
|
|
|
|
[hub]
|
|
|
|
http-clone = yes
|
|
|
|
|
|
|
|
|
2009-12-08 11:18:55 +03:00
|
|
|
Prior Art
|
2009-12-08 00:21:12 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
These projects also aim to either improve git or make interacting with
|
|
|
|
GitHub simpler:
|
|
|
|
|
|
|
|
* [eg](http://www.gnome.org/~newren/eg/)
|
|
|
|
* [github-gem](http://github.com/defunkt/github-gem)
|
|
|
|
* [gh](http://github.com/visionmedia/gh)
|
|
|
|
|
|
|
|
|
2009-12-08 11:18:55 +03:00
|
|
|
Contributing
|
|
|
|
------------
|
|
|
|
|
|
|
|
Once you've made your great commits:
|
|
|
|
|
|
|
|
1. [Fork][0] hub
|
|
|
|
2. Create a topic branch - `git checkout -b my_branch`
|
|
|
|
3. Push to your branch - `git push origin my_branch`
|
|
|
|
4. Create an [Issue][1] with a link to your branch
|
|
|
|
5. That's it!
|
|
|
|
|
2010-04-22 04:22:29 +04:00
|
|
|
### Development Gems
|
|
|
|
You will need the following gems (and their dependencies) to
|
|
|
|
contribute to `hub`:
|
|
|
|
|
|
|
|
* `rake` (`gem install rake`)
|
|
|
|
* `kicker` (`gem install kicker`)
|
|
|
|
* `turn` (`gem install turn`)
|
|
|
|
* `mg` (`gem install mg`)
|
|
|
|
* `ronn` (`gem install ronn`)
|
2010-11-22 23:49:02 +03:00
|
|
|
* `webmock` (`gem install webmock`)
|
2009-12-08 11:18:55 +03:00
|
|
|
|
2009-12-08 08:28:38 +03:00
|
|
|
Meta
|
|
|
|
----
|
2009-12-08 00:21:12 +03:00
|
|
|
|
2009-12-08 11:18:55 +03:00
|
|
|
* Code: `git clone git://github.com/defunkt/hub.git`
|
|
|
|
* Home: <http://github.com/defunkt/hub>
|
|
|
|
* Bugs: <http://github.com/defunkt/hub/issues>
|
|
|
|
* List: <http://groups.google.com/group/github>
|
2009-12-09 08:32:02 +03:00
|
|
|
* Test: <http://runcoderun.com/defunkt/hub>
|
2011-03-24 22:37:03 +03:00
|
|
|
* Gems: <http://gemcutter.org/gems/hub>
|
2009-12-08 11:18:55 +03:00
|
|
|
|
|
|
|
|
2010-11-22 23:49:05 +03:00
|
|
|
Authors
|
|
|
|
-------
|
2009-12-08 11:18:55 +03:00
|
|
|
|
2010-11-22 23:49:05 +03:00
|
|
|
<https://github.com/defunkt/hub/contributors>
|
2009-12-08 11:18:55 +03:00
|
|
|
|
|
|
|
[0]: http://help.github.com/forking/
|
|
|
|
[1]: http://github.com/defunkt/hub/issues
|
2010-01-24 01:10:03 +03:00
|
|
|
[speed]: http://gist.github.com/284823
|
2010-02-24 08:14:48 +03:00
|
|
|
[2]: http://github.com/guides/local-github-config
|
2011-03-22 21:26:40 +03:00
|
|
|
[gc]: https://twitter.com/brynary/status/49560668994674688
|