git-mate
A Git CLI extension for my personal workflow around git worktrees.
Built for Bash/Zsh in Linux. Likely works on macOS too. Windows/Powershell is not supported, WSL should work fine though.
Commands
Note: Some commands automatically cd into a different directory. This is only supported if you configure shell integration.
mate new <branch>
Creates a new branch from the default branch (e.g. main) and switches to it.
Choose to either check the branch out in the main worktree, or create a new linked worktree for it. Optionally, you may specify a different parent ref.
mate checkout <branch>
Checks out an existing branch — local or remote. If the branch already exists in a worktree, navigates there instead.
mate finish [<branch>]
You're done with a branch. Depending on where the branch is checked out:
- If it's in a linked worktree: removes the worktree and navigates back to the main worktree
- If it's checked out in the main worktree: switches to the default branch
mate sync
Fetches all remotes and prunes stale local tracking references, then pulls the current branch if an upstream is configured.
Installation
Shell Integration
Optionally add this to your shell config for shell completion and automatic cd support:
# ~/.zshrc or ~/.bashrc
Worktree location
Worktrees are created under a root directory, organized by repository and branch names. Set the root path in the git configuration:
# Set global defaults
# Override for a specific repo (run inside that repo)