Syntax
Description
Therepo get command clones a Git repository using a bare + worktree layout. This approach stores all Git data in a .bare directory and creates worktrees in separate subdirectories for each branch.
How It Works
- Cleans and normalizes the repository URL
- Determines the target directory under
$REPO_BASE_DIR - Performs a bare clone into
.baredirectory - Configures fetch refspecs for the remote
- Detects the default branch (typically
mainormaster) - Creates an initial worktree for the default branch
- Sets up upstream tracking
- Changes to the worktree directory
Arguments
The repository to clone. Supports multiple URL formats:
- Full URLs:
https://github.com/user/repo.git - SSH URLs:
[email protected]:user/repo.git - Short form:
github.com/user/repo - GitHub shorthand:
user/repo(automatically expands togithub.com/user/repo)
Examples
Clone from GitHub (full URL)
$REPO_BASE_DIR/github.com/torvalds/linux/ with the default branch worktree at $REPO_BASE_DIR/github.com/torvalds/linux/main/
Clone from GitHub (short form)
github.com/torvalds/linux and clones the repository.
Clone from GitLab
Clone using SSH URL
Behavior
Repository Already Exists
If the repository already exists: Worktree layout (.bare directory present):
.git directory present):
repo convert.
Directory Structure
After cloning, the repository structure looks like:Related Commands
- repo goto - Navigate to a cloned repository
- repo convert - Convert existing repositories to worktree layout
- repo list - List all cloned repositories
Common Use Cases
Clone and start working
Clone multiple repositories
$REPO_BASE_DIR by their hosting domain and path.
Implementation Details
Source code:functions/clone.zsh:1
The command uses git clone --bare followed by git worktree add to set up the repository structure. It automatically configures the fetch refspec with:
git fetch will update all remote branches correctly in the bare repository.