A neat little tool to make cloning of git repos a little more tidy.
Go to file
Masayuki Matsuki d4700da589
Merge pull request #371 from Okabe-Junya/fix-299
feat: implement `ghq rm` command
2024-02-02 10:42:44 +09:00
.github Merge pull request #359 from x-motemen/coverage 2023-04-16 23:27:26 +09:00
cmdutil migrate io/ioutil 2022-05-02 22:53:04 +09:00
logger Support pijul 2024-02-02 06:07:34 +09:00
misc Add spell check workflow 2023-02-22 15:35:22 +08:00
.gitignore ignore vscode and idea files 2020-06-03 23:54:37 +09:00
.tagpr release as draft by tagpr to hide it before uploading assets 2023-02-23 00:53:33 +09:00
CHANGELOG.md [tagpr] update CHANGELOG.md 2023-04-16 14:45:34 +00:00
cmd_create.go improve the error message if nothing is passed to ghq create 2022-03-12 10:59:18 +09:00
cmd_create_test.go Support pijul 2024-02-02 06:07:34 +09:00
cmd_get.go de-capitalize errors to make staticcheck happy 2023-02-23 16:01:00 +08:00
cmd_get_test.go de-capitalize errors to make staticcheck happy 2023-02-23 16:01:00 +08:00
cmd_list.go Adding another test case and running go fmt 2021-04-21 22:42:24 -05:00
cmd_list_test.go Use t.Cleanup to set environment variables in tests 2022-05-08 10:26:15 +09:00
cmd_rm.go feat: impl cmd_rm.go 2024-01-26 09:45:07 +09:00
cmd_rm_test.go feat: add unit test 2024-01-26 17:24:59 +09:00
cmd_root.go adjustment 2023-02-24 13:42:09 +08:00
cmd_root_test.go skip a test on windows 2023-02-22 20:42:28 +09:00
codecov.yml introduce codecov 2023-02-22 21:32:40 +09:00
commands.go feat: impl cmd_rm.go 2024-01-26 09:45:07 +09:00
commands_test.go Use t.Cleanup to remove temporally directories for tests 2022-05-08 10:09:00 +09:00
CREDITS make CREDITS 2024-01-26 17:25:15 +09:00
getter.go de-capitalize errors to make staticcheck happy 2023-02-23 16:01:00 +08:00
getter_test.go Remove trailing slash before stripping .git from the end 2020-06-29 23:51:09 +09:00
go.mod update deps 2023-04-16 23:33:39 +09:00
go.sum update deps 2023-04-16 23:33:39 +09:00
go_import.go Clone URLs by copying net.URL struct 2020-10-30 23:04:30 +01:00
go_import_test.go skip go-import mod 2019-05-12 15:14:56 +09:00
helpers_test.go de-capitalize errors to make staticcheck happy 2023-02-23 16:01:00 +08:00
helpers_unix.go refactor test helpers 2019-12-19 02:21:20 +09:00
helpers_windows.go refactor test helpers 2019-12-19 02:21:20 +09:00
LICENSE MIT license 2014-06-10 16:31:57 +09:00
local_repository.go Support pijul 2024-02-02 06:07:34 +09:00
local_repository_test.go skip a test on windows 2023-02-22 20:42:28 +09:00
main.go [tagpr] prepare for the next release 2023-04-16 14:45:33 +00:00
main_test.go fix test 2020-01-04 19:24:08 +09:00
Makefile remove gobin settings, there are already in path (#341) 2022-05-06 16:45:13 +09:00
README.adoc doc: update README 2024-01-26 17:30:17 +09:00
remote_repository.go Support pijul 2024-02-02 06:07:34 +09:00
remote_repository_test.go Support pijul 2024-02-02 06:07:34 +09:00
typos.toml Add spell check workflow 2023-02-22 15:35:22 +08:00
url.go de-capitalize errors to make staticcheck happy 2023-02-23 16:01:00 +08:00
url_test.go Use t.Cleanup for gitconfig.WithConfig 2022-05-08 10:37:32 +09:00
vcs.go Support pijul channels (like branches in git) 2024-02-02 07:39:15 +09:00
vcs_test.go Support pijul 2024-02-02 06:07:34 +09:00

= ghq(1) image:https://github.com/x-motemen/ghq/workflows/test/badge.svg?branch=master["Build Status", link="https://github.com/x-motemen/ghq/actions?workflow=test"] image:https://codecov.io/gh/x-motemen/ghq/branch/master/graph/badge.svg["Coverage", link="https://codecov.io/gh/x-motemen/ghq"]

== 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

[verse]
ghq get [-u] [-p] [--shallow] [--vcs <vcs>] [--look] [--silent] [--branch] [--no-recursive] [--bare] <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 root [--all]

== COMMANDS

get::
    Clone a remote repository under ghq root directory (see
    <<directory-structures,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.
    With '--bare' option, a "bare clone" will be performed (for Git
    repositories only, 'git clone --bare ...' 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.

== CONFIGURATION

Configuration uses 'git-config' variables.

ghq.root::
    The path to directory under which cloned repositories are placed. See
    <<directory-structures,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.

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


=== Example configuration (.gitconfig):

....
[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]]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/
....


== [[installing]]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
----

=== https://github.com/asdf-vm/asdf[asdf-vm]

----
asdf plugin add ghq
asdf install ghq latest
----

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

https://leanpub.com/ghq-handbook

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

https://github.com/Songmu/ghq-handbook

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

== AUTHOR

* motemen <motemen@gmail.com>
** https://github.com/sponsors/motemen
* Songmu <y.songmu@gmail.com>
** https://github.com/sponsors/Songmu