A utility script for cloning and setting up Git repositories as bare clones with an opinionated worktree-enabled structure.
Git worktrees are becoming the go-to solution for managing repositories with AI-driven development workflows, allowing developers to work on multiple features in parallel while your AI assistant works in separate branches without conflicts.
sudo mv ./git-worktree-setup.sh /usr/local/bin/git-worktree-setup
sudo chown root:wheel /usr/local/bin/git-worktree-setup
sudo chmod +x /usr/local/bin/git-worktree-setupβ
Now you have the git-worktree-setup command available in your shell.
git-worktree-setup <repository-url> <worktree-directory> [default-worktree-branch]git-worktree-setup git@github.com:username/repository.git ~/projects/repositoryThis will set up the repository as a bare clone with main as the initial worktree:
projects/
ββ repository/
β ββ .bare/ # Bare repository
β ββ main/ # Default worktree
Once set up, open each worktree in your IDE or Claude terminal session separately. This allows you to:
- β¨ Work on feature A in the
mainworktree - π€ Let Claude work on feature B in a separate worktree
- π― Avoid context switching and merge conflicts
- β‘ Switch between features instantly
We highly recommend Worktrunk for managing your worktrees. It's an amazing CLI tool that makes creating, switching, and deleting worktrees effortless.
Worktrunk fully supports bare repositories via configuration, making it the perfect companion to this setup script.
Happy parallel development! π