A command-line tool to clone Git repositories to a structured directory layout.
git-goget is a command-line tool that clones Git repositories to a structured directory layout under a configurable root directory. It supports various Git hosting services including GitHub, GitLab, Bitbucket, and others, following the pattern used by Go's workspace organization.
The tool operates silently without producing output unless there are errors.
-
Clone this repository or download the script
git clone https://github.com/hsbt/git-goget.git
-
Make the script executable
chmod +x git-goget/git-goget
-
Add the script to your PATH
# Copy to a directory in your PATH cp git-goget/git-goget /usr/local/bin/ # Or create a symlink ln -s /path/to/git-goget/git-goget /usr/local/bin/git-goget
-
Verify installation
git goget version
Clone a Git repository to the structured directory:
git goget <git-url>Clone to a custom root directory:
git goget --root <directory> <git-url>Show the tool version:
git goget versionDisplay help information:
git goget --helpThe root directory is determined by the following priority:
- --root option (highest priority)
- GIT_GOGET_ROOT environment variable
- git config user.rootDirectory value
- ~/src (default fallback)
# Clone Rails repository (uses priority system for root directory)
git goget https://github.com/rails/rails
# Set environment variable for session
export GIT_GOGET_ROOT=~/workspace
git goget https://github.com/rails/rails
# Clones to ~/workspace/github.com/rails/rails
# Set global default via git config
git config user.rootDirectory ~/myprojects
git goget https://gitlab.com/gitlab-org/gitlab
# Clones to ~/myprojects/gitlab.com/gitlab-org/gitlab
# Override with --root option
git goget --root ~/Documents https://github.com/rails/rails
# Clones to ~/Documents/github.com/rails/rails
# Clone using SSH URL
git goget [email protected]:rails/rails.git
# Show version information
git goget versionThe tool creates repositories in this structure:
With default root (~/src):
~/src/
├── github.com/
│ ├── rails/
│ │ └── rails/ # GitHub repository
│ └── hsbt/
│ └── gh-coauthor/
├── gitlab.com/
│ └── gitlab-org/
│ └── gitlab/ # GitLab repository
├── bitbucket.org/
│ └── atlassian/
│ └── stash/ # Bitbucket repository
└── other-host.com/
└── owner/
└── repo/ # Any other Git hosting service
With custom root (e.g., --root ~/Documents):
~/Documents/
├── github.com/
│ └── rails/
│ └── rails/
├── gitlab.com/
│ └── ...
└── ...
GIT_GOGET_ROOT- Set default root directory (overrides git config)
You can set a default root directory using git config:
# Set global default root directory
git config user.rootDirectory ~/myprojects
# Set repository-specific root directory
git config --local user.rootDirectory ~/work-projects
# Unset the configuration
git config --unset user.rootDirectorySet the GIT_GOGET_ROOT environment variable for temporary or session-based configuration:
# Set for current session
export GIT_GOGET_ROOT=~/workspace
# Set for single command
GIT_GOGET_ROOT=~/temp git goget https://github.com/example/repogit-goget automatically:
- Determines the root directory based on priority (--root > GIT_GOGET_ROOT > git config > ~/src)
- Parses the Git URL to extract host, owner and repository name
- Creates the directory structure
<root>/<host>/owner/repositoryif it doesn't exist - Clones the repository to the target directory (silent operation)
- If the directory already exists and contains a git repository, it runs
git pullto update it (silent operation)
The tool operates completely silently unless there are errors, making it ideal for scripts and automation.
- GitHub (github.com)
- GitLab (gitlab.com)
- Bitbucket (bitbucket.org)
- Any other Git hosting service that supports standard Git protocols
- HTTPS:
https://host.com/owner/repoorhttps://host.com/owner/repo.git - SSH:
[email protected]:owner/repo.git
Examples:
https://github.com/rails/railshttps://gitlab.com/gitlab-org/gitlab.git[email protected]:atlassian/stash.git
The project includes comprehensive test coverage using Bats (Bash Automated Testing System):
# Run tests locally (requires Bats installation)
bats test/git-goget.bats
# Install Bats on macOS
brew install bats-core
# Install Bats on Ubuntu/Debian
sudo apt-get install batsTests are automatically run on GitHub Actions for all pushes and pull requests to the main branch.