Last Updated: February 25, 2016
· motemen

ghq: Manage repository clones of GitHub, Google Code on the "Go way"

Every day you checkout source codes of tools, libraries, frameworks or so, to read them with your editor. It should be a good habit, but how do you manage local clones of repositories on GitHub or Google Code? Everytime thinking "this requires git clone and this one hg clone..."? In any way, they tend to be messy easily.

So here is one simple idea: do as go get does, but for any languages. And ghq is an implementation of this.

ghq is written in Go, so use go get to install it:

go get

Once installed, you can simply run ghq get REPOSITORY-URL to get it cloned under ghq's root (configurable by git config ghq.root, defaults to ~/.ghq), with a path according to its URL, for example ~/.ghq/

GitHub including GitHub:Enterprise and Google Code Project repositories (Git and Mercurial) are currently supposed.

% ghq get
     clone -> /Users/motemen/.ghq/
       git clone /Users/motemen/.ghq/
Cloning into '/Users/motemen/.ghq/'...

You can also list the repositories cloned, and look into one of the workspaces.

$ ghq list go # search local clones by "go"

$ ghq look vim
    cd /Users/motemen/.ghq/
$ # Launches a new shell with cwd set to the repo's workspace

And last but not least, ghq has a bulk-cloning feature. With the command below, you can get all the clones of GitHub repositories starred by a specific user.

$ ghq import starred motemen

ghq is yet under a heavy development and any issues or pull requests are welcome. Enjoy!

Say Thanks
Filed Under