ghq | Usage

# ghq | Usage
## 概要
ghq の各種コマンドの利用方法

## 設定
ghq の設定は ~/.gitconfig で行います。

|key|vlaue|
|:--|:--|
|ghq.root|clone したリポジトリの配置場所。デフォルトは `~/.ghq`|
|ghq.&lt;url&gt;.vcs|VCSの種類とURLの設定|
|ghq.import.&lt;subcommand&gt;|subcommand の追加設定|
|ghq.ghe.host|GitHub Enterprise の host|

## Commands
### get
ghq.root にリポジトリを clone する

* URL で clone

~~~bash
$ ghq get https://github.com/tbpgr/git_cloner.git
~~~

* user / project で clone 

~~~bash
$ ghq get tbpgr/aun
~~~

* clone 結果を確認

~~~bash
$ tree `ghq root` -L 3
~/.ghq
┗ github.com
    ┗ tbpgr
        ┣ aun
        ┗ git_cloner
~~~

### list

local 環境に clone しているリポジトリの一覧取得

~~~bash
$ ghq list
github.com/tbpgr/aun
github.com/tbpgr/git_cloner

$ ghq list aun
github.com/tbpgr/aun
~~~

### look
指定したリポジトリに移動する

~~~bash
$ ghq look aun
$ pwd
/path/to/home/.ghq/github.com/tbpgr/aun
~~~

### import
デフォルトで、引数を省略した場合には標準入力を利用した一括 clone 。
subcommand を利用する場合は、 `ghq import subcommand args` で利用する

~~~bash
$ ghq import
tbpgr/git_cloner
     clone https://github.com/tbpgr/git_cloner -> /path/to/home/.ghq/github.com/tbpgr/git_cloner
       git clone https://github.com/tbpgr/git_cloner /path/to/home/.ghq/github.com/tbpgr/git_cloner
Cloning into '/path/to/home/.ghq/github.com/tbpgr/git_cloner'...
remote: Counting objects: 294, done.
Receiving objects:  remote: Total 294 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (294/294), 32.83 KiB, done.
Resolving deltas: 100% (177/177), done.
tbpgr/gottani
     clone https://github.com/tbpgr/gottani -> /path/to/home/.ghq/github.com/tbpgr/gottani
       git clone https://github.com/tbpgr/gottani /path/to/home/.ghq/github.com/tbpgr/gottani
Cloning into '/path/to/home/.ghq/github.com/tbpgr/gottani'...
remote: Counting objects: 195, done.
remote: Total 195 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (195/195), 19.96 KiB, done.
Resolving deltas: 100% (109/109), done.
# Ctrl + C で終了
~~~

### root
ghq のルートディレクトリを表示

~~~bash
$ ghq root
/path/to/home/.ghq
~~~

### help
ヘルプの表示

* 全体

~~~bash
$ ghq help
NAME:
   ghq - Manage GitHub repository clones

USAGE:
   ghq [global options] command [command options] [arguments...]

VERSION:
   v0.5 (master)

AUTHOR:
  motemen - <motemen@gmail.com>

COMMANDS:
   get          Clone/sync with a remote repository
   list         List local repositories
   look         Look into a local repository
   import       Bulk get repositories from stdin
   root         Show repositories' root
   help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h           show help
   --version, -v        print the version
~~~

* 特定のコマンド

~~~
$ ghq help get
NAME:
    get - Clone/sync with a remote repository

USAGE:
    ghq get [-u] <repository URL> | [-u] [-p] <user>/<project>

DESCRIPTION:
    Clone a GitHub repository under ghq root direcotry. If the repository is
    already cloned to local, nothing will happen unless '-u' ('--update')
    flag is supplied, in which case 'git remote update' is executed.
    When you use '-p' option, the repository is cloned via SSH.


OPTIONS:
    --update, -u        Update local repository if cloned already
    -p                  Clone with SSH
    --shallow           Do a shallow clone
~~~

## 参照
[ghq GitHub](https://github.com/motemen/ghq)