Skip to content
Remote repository management made easy
Go Perl Shell Makefile
Branch: master
Clone or download
Songmu Checking in changes prior to tagging of version v1.0.2
## [v1.0.2](v1.0.1...v1.0.2) (2020-01-17)

* static build [#271](#271) ([Songmu](https://github.com/Songmu))
* Add options to zsh-completion [#270](#270) ([darklore](https://github.com/darklore))
* update ghq.root description in README [#269](#269) ([ksoichiro](https://github.com/ksoichiro))
* Enhance vcs_test.go [#266](#266) ([Songmu](https://github.com/Songmu))
* fix testing for 'ghq get --look' [#265](#265) ([Songmu](https://github.com/Songmu))
Latest commit 3981090 Jan 16, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github add FUNDING.yml Dec 31, 2019
cmdutil print command execution output to stderr Jan 1, 2020
logger
misc Add options to zsh-completion Jan 15, 2020
.gitignore Ignore ghq.exe Dec 4, 2019
CHANGELOG.md Checking in changes prior to tagging of version v1.0.2 Jan 16, 2020
CREDITS udpate CREDITS Dec 30, 2019
LICENSE MIT license Jun 10, 2014
Makefile static build Jan 16, 2020
README.adoc update ghq.root description in README Jan 15, 2020
cmd_create.go update urfave/cli deps to v2 Dec 25, 2019
cmd_create_test.go update for win Jan 4, 2020
cmd_get.go make ghq get -look work Jan 5, 2020
cmd_get_test.go fix testing for 'ghq get --look' Jan 5, 2020
cmd_list.go update urfave/cli deps to v2 Dec 25, 2019
cmd_list_test.go fix race conditions by using sync.Once Dec 28, 2019
cmd_root.go update urfave/cli deps to v2 Dec 25, 2019
cmd_root_test.go Merge branch 'master' into ghq-root Dec 28, 2019
commands.go fix docs Dec 30, 2019
commands_test.go adjust tests Jan 4, 2020
getter.go trivial fix Jan 4, 2020
getter_test.go refine local cloning path detection. fix #180 May 28, 2019
go.mod update deps Jan 16, 2020
go.sum update deps Jan 16, 2020
go_import.go
go_import_test.go skip go-import mod May 12, 2019
helpers_test.go refactor test helpers Dec 18, 2019
helpers_unix.go refactor test helpers Dec 18, 2019
helpers_windows.go refactor test helpers Dec 18, 2019
local_repository.go Merge branch 'master' into ghq-root Dec 28, 2019
local_repository_test.go adjust tests Jan 4, 2020
main.go Checking in changes prior to tagging of version v1.0.2 Jan 16, 2020
main_test.go fix test Jan 4, 2020
remote_repository.go detect VCS backend from scheme of URL Jan 1, 2020
remote_repository_test.go
url.go fix interface of newURL Dec 23, 2019
url_test.go adjust tests Jan 4, 2020
vcs.go print command execution output to stderr Jan 1, 2020
vcs_test.go add 'TestVCSBackend/[git-svn] clone specific branch from tagged URL w… Jan 5, 2020

README.adoc

ghq(1) Build Status Coverage

NAME

ghq - Manage remote repository clones

DESCRIPTION

'ghq' provides a way to organize remote repository clones, like go get does. When you clone a remote repository by ghq get, ghq makes a directory under a specific root directory (by default ~/ghq) using the remote repository URL’s host and path.

$ ghq get https://github.com/motemen/ghq
# Runs `git clone https://github.com/motemen/ghq ~/ghq/github.com/motemen/ghq`

You can also list local repositories (ghq list).

SYNOPSIS

ghq get [-u] [-p] [--shallow] [--vcs <vcs>] [--look] [--silent] [--branch] [--no-recursive] <repository URL>|<host>/<user>/<project>|<user>/<project>|<project>
ghq list [-p] [-e] [<query>]
ghq create [--vcs <vcs>] <repository URL>|<host>/<user>/<project>|<user>/<project>|<project>
ghq root [--all]

COMMANDS

get

Clone a remote repository under ghq root directory (see DIRECTORY STRUCTURES below). If the repository is already cloned to local, nothing will happen unless '-u' ('--update') flag is supplied, in which case the local repository is updated ('git pull --ff-only' eg.). When you use '-p' option, the repository is cloned via SSH protocol.
If there are multiple ghq.root s, existing local clones are searched first. Then a new repository clone is created under the primary root if none is found.
With '--shallow' option, a "shallow clone" will be performed (for Git repositories only, 'git clone --depth 1 …​' eg.). Be careful that a shallow-cloned repository cannot be pushed to remote. Currently Git and Mercurial repositories are supported.
With '--branch' option, you can clone the repository with specified repository. This option is currently supported for Git, Mercurial, Subversion and git-svn.
The 'ghq' gets the git repository recursively by default.
We can prevent it with '--no-recursive' option.

list

List locally cloned repositories. If a query argument is given, only repositories whose names contain that query text are listed. '-e' ('--exact') forces the match to be an exact one (i.e. the query equals to project, user/project or host/user/project) If '-p' ('--full-path') is given, the full paths to the repository root are printed instead of relative ones.

root

Prints repositories' root (i.e. ghq.root). Without '--all' option, the primary one is shown.

create

Creates new repository.

CONFIGURATION

Configuration uses 'git-config' variables.

ghq.root

The path to directory under which cloned repositories are placed. See DIRECTORY STRUCTURES below. Defaults to ~/ghq.
This variable can have multiple values. If so, the last one becomes primary one i.e. new repository clones are always created under it. You may want to specify "$GOPATH/src" as a secondary root (environment variables should be expanded.)

ghq.<url>.vcs

ghq tries to detect the remote repository’s VCS backend for non-"github.com" repositories. With this option you can explicitly specify the VCS for the remote repository. The URL is matched against '<url>' using 'git config --get-urlmatch'.
Accepted values are "git", "github" (an alias for "git"), "subversion", "svn" (an alias for "subversion"), "git-svn", "mercurial", "hg" (an alias for "mercurial"), "darcs", "fossil", "bazaar", and "bzr" (an alias for "bazaar").
To get this configuration variable effective, you will need Git 1.8.5 or higher.
For example in .gitconfig:

ghq.<url>.root

The "ghq" tries to detect the remote repository-specific root directory. With this option, you can specify a repository-specific root directory instead of the common ghq root directory.
The URL is matched against '<url>' using 'git config --get-urlmatch'.

[ghq "https://git.example.com/repos/"]
vcs = git
root = ~/myproj

ENVIRONMENT VARIABLES

GHQ_ROOT

If set to a path, this value is used as the only root directory regardless of other existing ghq.root settings.

DIRECTORY STRUCTURES

Local repositories are placed under 'ghq.root' with named github.com/user/repo.

~/ghq
|-- code.google.com/
|   `-- p/
|       `-- vim/
`-- github.com/
    |-- google/
    |   `-- go-github/
    |-- motemen/
    |   `-- ghq/
    `-- urfave/
        `-- cli/

INSTALLATION

homebrew

brew install ghq

go get

go get github.com/motemen/ghq

build

git clone https://github.com/motemen/ghq .
make install

Built binaries are available from GitHub Releases. https://github.com/motemen/ghq/releases

HANDBOOK

You can buy "ghq-handbook" from Leanpub for more detailed usage.

https://leanpub.com/ghq-handbook (Currently Japanese Only)

The source Markdown files of this book are also available for free from the following repository.

You can’t perform that action at this time.