A ZSH plugin for managing git repositories using a worktree-first workflow. Repos are cloned as bare repositories with worktrees for each branch, enabling instant context switching without stashing or checkout thrashing.
- antidote
# in your .zsh_plugins.txt
abs3ntdev/repo-manager- sheldon
sheldon add repo-manager --github abs3ntdev/repo-manager
- zinit
zinit light abs3ntdev/repo-manager
Usage: repo <command> [arguments]
Commands:
get <repo> Clone a repository (bare + worktree layout)
open Open the current repository in the browser
aur <repo> Clone an AUR repository
list List all repositories
go|goto <repo> Navigate to a repository (worktree picker if applicable)
new|create <repo> Create a new repository
convert [path] Convert a standard clone to worktree layout
wt <subcommand> Worktree management (run from inside a repo)
help Show this help message
Worktree subcommands:
wt add <branch> Create a new worktree for a branch
wt list List all worktrees for the current repo
wt rm <branch> Remove a worktree
wt go <branch> Switch to a worktree
wt pr <number> Create a worktree from a GitHub PR
wt clean Remove all worktrees except the default branch
Examples:
repo get github.com/user/repo
repo goto user/repo
repo wt add feature-auth
repo wt pr 123
repo wt clean
repo convert
After repo get github.com/user/repo:
$REPO_BASE_DIR/github.com/user/repo/
├── .bare/ # bare git repo
├── .git # file pointing to .bare
├── main/ # worktree for default branch
├── feature-auth/ # worktree added via repo wt add
└── fix-crash/ # worktree added via repo wt pr
Clone a repo and start working:
repo get github.com/user/repo # bare clone + main worktree, cd's into main/
repo wt add feature-auth # create worktree for new branch, cd's into itContext switch to review a PR:
repo wt pr 42 # fetch PR #42, create worktree, cd into itSwitch between worktrees:
repo wt go main # cd to main worktree
repo wt go feature-auth # cd to feature-auth worktree
repo wt list # see all worktreesClean up after a review session:
repo wt rm fix-crash # remove one worktree
repo wt clean # remove all worktrees except default branchNavigate to a repo from anywhere (fzf picker if multiple worktrees exist):
repo goto user/repoMigrate an existing standard clone:
cd ~/repos/github.com/user/repo
repo convertfzf- worktree picker when navigating to a repo with multiple worktrees viarepo gotogh- GitHub CLI, required forrepo wt prto create worktrees from pull requests
Hooks are configured by overriding the functions provided in hooks.zsh. The default hooks are:
post_repo_clone() { cd "$1" }
post_repo_goto() { cd "$1" }
post_repo_new() { cd "$1" }
post_wt_add() { cd "$1" }
post_wt_go() { cd "$1" }
post_wt_rm() { : }Override these in your .zshrc to customize behavior:
post_repo_clone() {
cd "$1" && code .
}
post_wt_add() {
cd "$1" && code .
}The base directory is set via ENV. The default is $HOME/repos. You can change this by adding the following to your .zshrc:
export REPO_BASE_DIR="whatever/you/want"