GitHubのコードをよく使っているので、ローカルのストレージのあちこちにリポジトリが散在してしまっています。同じリポジトリを別な場所でクローンしているケースも少なくありません。 そんな状態を防ぐのに使えそうなのがghqです。リポジトリをまとめて一つのディレクトリ配下に置いてくれます。

ghqの使い方

ghqはGoのようにgetコマンドでリポジトリを取得します。

$ ghq get git@github.com:online-meetup-dev/online-meetup-dev.github.io.git
     clone ssh://git@github.com/online-meetup-dev/online-meetup-dev.github.io.git -> ~/ghq/github.com/online-meetup-dev/online-meetup-dev.github.io
       git clone --recursive ssh://git@github.com/online-meetup-dev/online-meetup-dev.github.io.git ~/ghq/github.com/online-meetup-dev/online-meetup-dev.github.io
Cloning into '~/ghq/github.com/online-meetup-dev/online-meetup-dev.github.io'...
remote: Enumerating objects: 131, done.
remote: Counting objects: 100% (131/131), done.
remote: Compressing objects: 100% (95/95), done.
remote: Total 1961 (delta 70), reused 97 (delta 36), pack-reused 1830
Receiving objects: 100% (1961/1961), 347.96 KiB | 682.00 KiB/s, done.
Resolving deltas: 100% (1017/1017), done.

listコマンドで一覧を取れます。

$ ghq list
github.com/online-meetup-dev/online-meetup-dev.github.io

ghqを使えばすべてのリポジトリが ~/ghq 以下に入ります。これは以外と便利で、.gitディレクトリは以外と大きいこともあるので、巨大なリポジトリを探すのも簡単になりそうです。ローカルであれば、このリポジトリをシンボリックリンクで使うのもよさそうです。

ghqはGo製のオープンソース・ソフトウェア(MIT License)です。

x-motemen/ghq: Remote repository management made easy