README.md 4.3 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 11 12 13 14 15 16 17

    $ hub clone rtomayko/tilt
    Initialized empty Git repository in /Users/chris/sandbox/tilt/.git/
    remote: Counting objects: 307, done.
    remote: Compressing objects: 100% (219/219), done.
    remote: Total 307 (delta 175), reused 85 (delta 45)
    Receiving objects: 100% (307/307), 48.91 KiB, done.
    Resolving deltas: 100% (175/175), done.

C
Chris Wanstrath 已提交
18
Wrapping `git`:
C
Chris Wanstrath 已提交
19 20 21 22 23 24 25 26 27

    $ git clone rack/rack
    Initialized empty Git repository in /Users/chris/sandbox/rack/.git/
    remote: Counting objects: 4005, done.
    remote: Compressing objects: 100% (1738/1738), done.
    remote: Total 4005 (delta 2505), reused 3620 (delta 2208)
    Receiving objects: 100% (4005/4005), 785.82 KiB | 129 KiB/s, done.
    Resolving deltas: 100% (2505/2505), done.

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

C
readme  
Chris Wanstrath 已提交
31

C
Chris Wanstrath 已提交
32
Install
C
readme  
Chris Wanstrath 已提交
33 34
-------

C
Chris Wanstrath 已提交
35 36
### Standalone

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

C
Caio Chassot 已提交
39
    curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub && chmod 755 !#:4
C
Chris Wanstrath 已提交
40

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

C
Chris Wanstrath 已提交
43 44 45
    $ hub version
    git version 1.6.4.2
    hub version 0.1.0
C
Chris Wanstrath 已提交
46

47
### RubyGems
C
Chris Wanstrath 已提交
48

49
Though not recommended, `hub` can also be installed as a RubyGem:
C
Chris Wanstrath 已提交
50 51 52 53 54

    $ gem install git-hub -s http://gemcutter.org/

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

C
Chris Wanstrath 已提交
55 56
### Source

C
Chris Wanstrath 已提交
57
You can also install from source:
C
readme  
Chris Wanstrath 已提交
58 59 60

    $ git clone git://github.com/defunkt/hub.git
    $ cd hub
C
Chris Wanstrath 已提交
61 62
    $ rake standalone
    $ cp hub /usr/local/bin/
C
readme  
Chris Wanstrath 已提交
63 64


C
Chris Wanstrath 已提交
65 66
Aliasing
--------
C
readme  
Chris Wanstrath 已提交
67

C
Chris Wanstrath 已提交
68 69
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 已提交
70

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

C
Chris Wanstrath 已提交
74 75 76 77 78 79 80
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 已提交
81
script to ensure runs on login.
C
Chris Wanstrath 已提交
82 83 84 85

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

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

C
readme  
Chris Wanstrath 已提交
87

C
Chris Wanstrath 已提交
88
Commands
C
readme  
Chris Wanstrath 已提交
89 90
--------

C
Chris Wanstrath 已提交
91
Assuming you've aliased `hub` to `git` the following commands now have
C
Chris Wanstrath 已提交
92 93
superpowers:

C
readme  
Chris Wanstrath 已提交
94 95 96
### git clone

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

C
readme  
Chris Wanstrath 已提交
99
    $ git clone -p schacon/ticgit
C
Chris Wanstrath 已提交
100
    > git clone git@github.com:schacon/ticgit.git
C
readme  
Chris Wanstrath 已提交
101

102 103 104 105 106 107
    $ 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 已提交
108 109 110
### git remote add

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

K
Konstantin Haase 已提交
113
    $ git remote add -p rtomayko
C
Chris Wanstrath 已提交
114
    > git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git
C
readme  
Chris Wanstrath 已提交
115 116 117

### git init

C
Chris Wanstrath 已提交
118
    $ git init -g
C
Chris Wanstrath 已提交
119
    > git init
120
    > git remote add origin git@github.com:YOUR_USER/REPO.git
C
Chris Wanstrath 已提交
121 122 123 124 125

### git help

    $ git help
    > (improved git help)
C
readme  
Chris Wanstrath 已提交
126 127


C
Chris Wanstrath 已提交
128 129 130 131 132 133 134 135 136 137 138 139
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 已提交
140
    $ git config --global github.user YOUR_USER
C
Chris Wanstrath 已提交
141 142 143 144

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


C
Chris Wanstrath 已提交
145
Prior Art
C
readme  
Chris Wanstrath 已提交
146 147 148 149 150 151 152 153 154 155
---------

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 已提交
156 157 158 159 160 161 162 163 164 165 166 167
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 已提交
168 169
Meta
----
C
readme  
Chris Wanstrath 已提交
170

C
Chris Wanstrath 已提交
171 172 173 174
* 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 已提交
175 176
* Test: <http://runcoderun.com/defunkt/hub>
* Gems: <http://gemcutter.org/gems/git-hub>
C
Chris Wanstrath 已提交
177 178 179 180 181 182 183 184 185


Author
------

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

[0]: http://help.github.com/forking/
[1]: http://github.com/defunkt/hub/issues