Skip to content
프로젝트

소개

원격 저장소를 손쉽게 관리

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+3
in 7 days
+4
in 15 days
+17
in 1 month
+33

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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/x-motemen/ghq
# Runs `git clone https://github.com/x-motemen/ghq ~/ghq/github.com/x-motemen/ghq`

You can also list local repositories (ghq list).

SYNOPSIS

ghq get [-u] [-p] [--shallow] [--vcs <vcs>] [--look] [--silent] [--branch] [--no-recursive] [--bare] [--clean-bare] [--partial blobless|treeless] <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 rm [--dry-run] <repository URL>|<host>/<user>/<project>|<user>/<project>|<project>
ghq migrate [-y] [--dry-run] <local repository path>
ghq root [--all]

COMMANDS

get

Clone a remote repository under ghq root directory (see DIRECTORY STRUCTURES below). ghq clone is an alias for this command. 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 branch. 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. With '--bare' option, a "bare clone" will be performed (for Git repositories only, 'git clone --bare …​' eg.). The on-disk directory receives a '.git' suffix (e.g. '<root>/host/user/repo.git').
With '--clean-bare' option, a bare clone is performed but the bare gitdir is placed as a '.git' subdirectory of an unsuffixed parent (e.g. '<root>/host/user/repo/.git'). This layout keeps the repository directory name clean and allows Git worktrees to live as sibling subdirectories:

repo/
├── .git/       # bare repository
├── main/       # worktree
├── feature/    # worktree
└── bugfix/     # worktree

'--clean-bare' implies '--bare'. Passing both together is not an error: '--bare' is ignored (with a warning) and the clone follows the '--clean-bare' layout.
With '--partial' option, a "partial clone" will be performed (for Git repositories only, in 'blobless' mode, 'git clone --filter=blob:none …​', in 'treeless' mode, 'git clone --filter=tree:0 …​' eg.).

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.

rm

Remove local repository. If '--dry-run' option is given, the repository is not actually removed but the path to it is printed.

create

Creates new repository.

migrate

Migrate an existing repository directory to the ghq-managed directory structure. The command detects the VCS backend, retrieves the remote URL, and moves the repository to the appropriate location under ghq root.

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.user

In ghq, when specifying only the repository name without slashes as in ghq get {{Project}}, ghq attempts to auto-complete the repository owner. By default, the owner used is the value of the environment variable USER (or USERNAME on Windows). Setting this option allows you to explicitly specify the owner.

ghq.completeUser

Rather than always using your own username for owner completion, you may want to complete the owner with the same name as the repository. For example, fetch ruby as github.com/ruby/ruby, vim as github.com/vim/vim, and peco as github.com/peco/peco. If you prefer this behavior, set this option to false to switch the owner completion method.

ghq.defaultHost

The default host used when the repository specification omits the host. For example, ghq get owner/project normally resolves to github.com/owner/project. If this option is set, the specified host will be used instead.

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.

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'.

Since ghq get runs git clone for Git repositories, git’s own configuration applies as well. For example, clone.defaultRemoteName changes the name of the created remote, which is origin by default.
To get this configuration variable effective, you will need Git 2.30 or higher.

Example configuration (.gitconfig):

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

The subsection URL selects remote URLs to which these settings apply; it is not a local path or a URL rewrite. In this example, repositories under https://git.example.com/repos/ use Git and are cloned beneath ~/myproj. For example, ghq get https://git.example.com/repos/team/tool creates a new clone at ~/myproj/git.example.com/repos/team/tool. The hostname and repository path are preserved; root only changes the directory beneath which they are placed. See Git’s URL matching rules for details.

HTTPS and SSH URLs are matched separately. To apply the same settings to [email protected]:repos/team/tool, which ghq normalizes to ssh://[email protected]/repos/team/tool, add an SSH subsection:

[ghq "ssh://[email protected]/repos/"]
vcs = git
root = ~/myproj

If the repository already exists under one of the configured roots, ghq reuses that clone rather than moving it to the URL-specific root. Setting GHQ_ROOT overrides both the common and URL-specific roots.

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

macOS

brew install ghq

Void Linux

xbps-install -S ghq

GNU Guix

guix install ghq

Windows + scoop

scoop install ghq

go get

go install github.com/x-motemen/ghq@latest

conda

conda install -c conda-forge go-ghq
asdf plugin add ghq
asdf install ghq latest
mise install ghq
mise use ghq
nix run nixpkgs#ghq # run ghq once
nix profile install nixpkgs#ghq # install ghq to your profile

build

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

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

HANDBOOK

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

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

Currently, only Japanese version available. Your translations are welcome!

관련 프로젝트 살펴보기

불러오는 중…