README.md 5.1 KB
Newer Older
C
Chris Wanstrath 已提交
1 2
hub: git + hub = github
=======================
C
readme  
Chris Wanstrath 已提交
3

C
Chris Wanstrath 已提交
4
`hub` is a command line utility which adds GitHub knowledge to `git`.
C
readme  
Chris Wanstrath 已提交
5

C
Chris Wanstrath 已提交
6
It can used on its own or as a `git` wrapper.
C
readme  
Chris Wanstrath 已提交
7

C
Chris Wanstrath 已提交
8
Normal:
C
Chris Wanstrath 已提交
9 10

    $ hub clone rtomayko/tilt
11 12 13
    
    Expands to:
    $ git clone git://github.com/rtomayko/tilt.git
C
Chris Wanstrath 已提交
14

C
Chris Wanstrath 已提交
15
Wrapping `git`:
C
Chris Wanstrath 已提交
16 17 18

    $ git clone rack/rack

19
hub requires you have `git` installed and in your `$PATH`. It also
C
Chris Wanstrath 已提交
20
requires Ruby 1.8.6+ or Ruby 1.9.1+. No other libraries necessary.
C
tweaks  
Chris Wanstrath 已提交
21

C
readme  
Chris Wanstrath 已提交
22

C
Chris Wanstrath 已提交
23
Install
C
readme  
Chris Wanstrath 已提交
24 25
-------

C
Chris Wanstrath 已提交
26 27
### Standalone

C
tweaks  
Chris Wanstrath 已提交
28
`hub` is most easily installed as a standalone script:
C
Chris Wanstrath 已提交
29

C
Chris Wanstrath 已提交
30 31
    curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub &&
    chmod 755 ~/bin/hub
C
Chris Wanstrath 已提交
32

33
Assuming `~/bin/` is in your `$PATH`, you're ready to roll:
C
Chris Wanstrath 已提交
34

C
Chris Wanstrath 已提交
35 36
    $ hub version
    git version 1.6.4.2
37
    hub version 0.3.2
C
Chris Wanstrath 已提交
38

39 40
### Homebrew

D
defunkt 已提交
41
    brew install hub
42

43
### RubyGems
C
Chris Wanstrath 已提交
44

45
Though not recommended, `hub` can also be installed as a RubyGem:
C
Chris Wanstrath 已提交
46

C
Chris Wanstrath 已提交
47
    $ gem install git-hub
C
Chris Wanstrath 已提交
48 49 50

(Yes, the gem name is `git-hub`.)

51 52 53
(It's not recommended because of the RubyGems startup time. See [this
gist][speed] for information.)

54 55 56 57 58 59 60 61
### Standalone via RubyGems

Yes, the gem name is still `git-hub`:

    $ gem install git-hub
    $ hub hub standalone > ~/bin/hub && chmod 755 ~/bin/hub
    $ gem uninstall git-hub

C
Chris Wanstrath 已提交
62 63
### Source

C
Chris Wanstrath 已提交
64
You can also install from source:
C
readme  
Chris Wanstrath 已提交
65 66 67

    $ git clone git://github.com/defunkt/hub.git
    $ cd hub
68
    $ rake install prefix=/usr/local
C
readme  
Chris Wanstrath 已提交
69 70


C
Chris Wanstrath 已提交
71 72
Aliasing
--------
C
readme  
Chris Wanstrath 已提交
73

C
Chris Wanstrath 已提交
74 75
hub works best when it wraps `git`. This is not dangerous - your
normal git commands should all work. hub merely adds some sugar.
C
readme  
Chris Wanstrath 已提交
76

C
Chris Wanstrath 已提交
77 78
Typing `hub alias <shell>` will display alias instructions for
your shell. `hub alias` alone will show the known shells.
C
readme  
Chris Wanstrath 已提交
79

C
Chris Wanstrath 已提交
80 81 82 83 84 85 86
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
C
Chris Wanstrath 已提交
87
script to ensure runs on login.
C
Chris Wanstrath 已提交
88 89 90 91

The alias command can also be eval'd directly using the `-s` flag:

    $ eval `hub alias -s bash`
C
tweaks  
Chris Wanstrath 已提交
92

C
readme  
Chris Wanstrath 已提交
93

C
Chris Wanstrath 已提交
94
Commands
C
readme  
Chris Wanstrath 已提交
95 96
--------

C
Chris Wanstrath 已提交
97
Assuming you've aliased `hub` to `git` the following commands now have
C
Chris Wanstrath 已提交
98 99
superpowers:

C
readme  
Chris Wanstrath 已提交
100 101 102
### git clone

    $ git clone schacon/ticgit
C
Chris Wanstrath 已提交
103 104
    > git clone git://github.com/schacon/ticgit.git

C
readme  
Chris Wanstrath 已提交
105
    $ git clone -p schacon/ticgit
C
Chris Wanstrath 已提交
106
    > git clone git@github.com:schacon/ticgit.git
C
readme  
Chris Wanstrath 已提交
107

108 109 110 111 112 113
    $ 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

C
readme  
Chris Wanstrath 已提交
114 115 116
### git remote add

    $ git remote add rtomayko
C
Chris Wanstrath 已提交
117 118
    > git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git

K
Konstantin Haase 已提交
119
    $ git remote add -p rtomayko
C
Chris Wanstrath 已提交
120
    > git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git
C
readme  
Chris Wanstrath 已提交
121

122 123 124
    $ git remote add origin
    > git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git

C
readme  
Chris Wanstrath 已提交
125 126
### git init

C
Chris Wanstrath 已提交
127
    $ git init -g
C
Chris Wanstrath 已提交
128
    > git init
129
    > git remote add origin git@github.com:YOUR_USER/REPO.git
C
Chris Wanstrath 已提交
130

131 132 133 134 135 136 137
### git push

    $ git push origin,staging,qa bert_timeout
    > git push origin bert_timeout
    > git push staging bert_timeout
    > git push qa bert_timeout

138 139
### git browse

140 141 142
    $ git browse
    > open http://github.com/CURRENT_REPO

143 144 145 146 147 148 149 150 151 152 153 154
    $ git browse schacon/ticgit
    > open http://github.com/schacon/ticgit

    $ git browse -p schacon/ticgit
    > open http://github.com/schacon/ticgit

    $ git browse resque
    > open http://github.com/YOUR_USER/resque

    $ git browse -p resque
    > open https://github.com:YOUR_USER/resque

C
Chris Wanstrath 已提交
155 156 157 158
### git help

    $ git help
    > (improved git help)
C
Chris Wanstrath 已提交
159 160
    $ git help hub
    > (hub man page)
C
readme  
Chris Wanstrath 已提交
161 162


C
Chris Wanstrath 已提交
163 164 165 166 167 168 169 170 171 172 173 174
GitHub Login
------------

To get the most out of `hub`, you'll want to ensure your GitHub login
is stored locally in your Git config.

To test it run this:

    $ git config --global github.user

If you see nothing, you need to set the config setting:

C
Chris Wanstrath 已提交
175
    $ git config --global github.user YOUR_USER
C
Chris Wanstrath 已提交
176 177 178 179

See <http://github.com/guides/local-github-config> for more information.


C
Chris Wanstrath 已提交
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
Configuration
-------------

If you prefer `http://` clones to `git://` clones, you can set the
`hub.http-clone` option using `git-config`.

For example:

    $ git clone defunkt/repl
    < git clone >
    $ git config --global --add hub.http-clone yes
    $ git clone defunkt/repl
    < http clone >

Or you can enter this manually into your `~/.gitconfig` file:

    $ cat ~/.gitconfig
    [hub]
      http-clone = yes


C
Chris Wanstrath 已提交
201
Prior Art
C
readme  
Chris Wanstrath 已提交
202 203 204 205 206 207 208 209 210 211
---------

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)


C
Chris Wanstrath 已提交
212 213 214 215 216 217 218 219 220 221 222 223
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!


C
Chris Wanstrath 已提交
224 225
Meta
----
C
readme  
Chris Wanstrath 已提交
226

C
Chris Wanstrath 已提交
227 228 229 230
* 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>
C
Chris Wanstrath 已提交
231 232
* Test: <http://runcoderun.com/defunkt/hub>
* Gems: <http://gemcutter.org/gems/git-hub>
C
Chris Wanstrath 已提交
233 234 235 236 237 238 239 240 241


Author
------

Chris Wanstrath :: chris@ozmm.org :: @defunkt

[0]: http://help.github.com/forking/
[1]: http://github.com/defunkt/hub/issues
242
[speed]: http://gist.github.com/284823