π Smart Git Repository Cloner - Clone repositories into organized directory structures with parallel processing
Ever tired of manually creating nested directories for your Git repositories? gclone automatically organizes your repos into a clean, predictable structure that mirrors the repository's URL path, with blazing-fast parallel processing.
~/src/
βββ github.com/
β βββ golang/go/
β βββ kubernetes/kubernetes/
β βββ juev/gclone/
βββ gitlab.com/
β βββ company/project/
βββ bitbucket.org/
βββ team/service/
- β‘ Parallel Processing - Clone multiple repositories simultaneously with configurable workers
- π― Zero Configuration - Works out of the box with sensible defaults
- π Organized Structure - Mirrors repository URLs in your filesystem
- π Security First - Comprehensive URL validation and path sanitization
- πΎ Smart Caching - Intelligent directory existence checking with LRU cache
- π Shallow Clones - Optional
--depth=1
for faster clones - π‘οΈ Graceful Shutdown - Handles interrupts cleanly with signal handling
- π€« Quiet Mode - Suppress output when needed
- π Shell Integration - Perfect for scripts and aliases
go install github.com/juev/gclone@latest
# Set your preferred projects directory
export GIT_PROJECT_DIR="$HOME/src"
# Clone a single repository
gclone https://github.com/golang/go.git
# Result: ~/src/github.com/golang/go/
# Clone multiple repositories in parallel
gclone https://github.com/golang/go.git \
https://github.com/kubernetes/kubernetes.git \
https://gitlab.com/company/project.git
# Fast shallow clone
gclone --shallow https://github.com/large/repository.git
# Use 8 parallel workers for faster cloning
gclone -w 8 \
https://github.com/repo1/project.git \
https://github.com/repo2/project.git \
https://github.com/repo3/project.git
# Quiet mode for scripts
gclone --quiet --shallow https://github.com/user/repo.git
# Chain with other commands
cd "$(gclone https://github.com/user/repo.git)"
code "$(gclone --quiet https://github.com/user/repo.git)"
gclone [-h] [-v] [-q] [-s] [-w WORKERS] [REPOSITORY...]
Options:
-h, --help Show this help message and exit
-v, --version Show the version number and exit
-q, --quiet Suppress output
-s, --shallow Perform shallow clone with --depth=1
-w, --workers Number of parallel workers (default: 4, max: 32)
Environment Variables:
GIT_PROJECT_DIR Directory to clone repositories (default: current dir)
Examples:
GIT_PROJECT_DIR="$HOME/src" gclone https://github.com/user/repo
gclone -w 8 https://github.com/user/repo1 https://github.com/user/repo2
# Clone and cd into repository
gcd() {
cd "$(gclone "$1")"
}
# Clone and open in VS Code
gcode() {
code "$(gclone "$1")"
}
# Clone and open in your editor
gedit() {
$EDITOR "$(gclone "$1")"
}
# Bulk clone with parallel processing
gbulk() {
gclone -w 8 "$@"
}
function gcd --argument repo
test -n "$repo"; or return 1
cd (gclone $repo)
end
function gcode --argument repo
test -n "$repo"; or return 1
code (gclone $repo)
end
function gbulk
gclone -w 8 $argv
end
function gcd($repo) {
Set-Location (gclone $repo)
}
function gcode($repo) {
code (gclone $repo)
}
function gbulk {
gclone -w 8 @args
}
- Parse & Validate - Security validation of repository URLs
- Normalize - Convert URLs to filesystem paths (with caching)
- Parallel Process - Distribute work across configurable workers
- Smart Check - Cache-optimized directory existence checking
- Secure Clone - Timeout-protected git operations
- Signal Handling - Graceful shutdown on interrupts
- URL Validation - Comprehensive security checks against malicious URLs
- Path Sanitization - Protection against directory traversal attacks
- Command Safety - No shell interpretation, direct git execution
- Timeout Protection - 10-minute timeout per repository
- Safe Defaults - Conservative permissions (0750) for created directories
- Parallel Workers - Configurable concurrent cloning (1-32 workers)
- Smart Caching - LRU cache for directory existence checks
- Regex Pooling - Optimized URL parsing with pattern-specific regex
- Sequential Fallback - Automatic optimization for single repositories
- Memory Efficient - Streaming directory reads, minimal allocations
- π Learning - Quickly clone course materials and tutorials
- π§ Development - Maintain consistent project structure across teams
- π€ CI/CD - Bulk repository setup in automation pipelines
- π Research - Rapidly explore multiple open source projects
- π Backup - Mirror repositories locally with organized structure
- π’ Enterprise - Standardized repository organization
The tool provides detailed feedback during operation:
# Progress indicators for multiple repositories
gclone repo1.git repo2.git repo3.git
# processed 3 repositories: 2 successful, 1 failed
# Existing repositories are detected
gclone https://github.com/existing/repo.git
# repository already exists: /home/user/src/github.com/existing/repo
# Graceful interrupt handling
^C Received signal interrupt, initiating graceful shutdown...
Graceful shutdown completed.
Contributions are welcome! The codebase features:
- Dependency Injection - Clean interfaces for testability
- Comprehensive Testing - Full test coverage with mocks
- Security Focus - Multiple layers of validation
- Performance Optimization - Caching, pooling, and parallelization
MIT License - see LICENSE file for details.
Made with β€οΈ by developers, for developers
β Star this repo if it helps you stay organized and productive!