A helper tool for cloning bare repositories and managing clean, isolated Git worktrees with minimal friction.
rustree streamlines a powerful Git workflow: one bare repository + multiple lightweight working directories, each tied to a branch.
When working on multiple branches simultaneously (features, tickets, hotfixes), the typical workflow looks like:
- Stash changes
- Checkout another branch
- Pull
- Repeat
Or you clone the same repository multiple times. Both approaches are messy.
Git worktrees solve this problem — but managing them manually is tedious.
rustree automates this by:
- Cloning a repository as a bare repo
- Creating a clean structure for multiple worktrees
- Automatically handling SSH keys
- Managing branch creation and upstream tracking Result: clean separation between branches, no stashing, no duplicate clones.
After cloning and creating worktrees, your project structure will look like this:
project
├── .bare
│ └...
├── .git
├── main
│ ├── .git
│ ├── .gitignore
│ ├── LICENSE
│ └── README.md
└── TICKET-123
├── .git
├── .gitignore
├── LICENSE
└── README.md
Explanation
.bare/→ the actual Git repository (bare).git→ points to.baremain/→ worktree formainbranchTICKET-123/→ worktree for a feature branch
Each directory is an isolated working copy, backed by the same Git object database.
Work on multiple branches simultaneously without:
git stash- Dirty working trees
- Context switching headaches
Instead of:
project-main/
project-feature/
project-hotfix/
You get:
project/
├── .bare/
├── main/
├── feature/
└── hotfix/
One object database. Multiple working directories.
Each branch:
- Has its own folder
- Has its own build artifacts
- Has its own environment
Perfect for:
- Large builds
- Docker projects
- Python virtual environments
- Monorepos
You can:
- Keep
main/clean. You always have a working version of your code ready to go - Test features in isolation
- Compare branches side by side
cargo install --path .
Or build manually:
cargo build --release
Helper tool that helps you cloning bare repositories and managing git worktrees for a bare repository
Usage: rustree <COMMAND>
Commands:
clone Clone something
worktree Manage worktrees
list List all git worktrees inside a repository
rm-worktree Remove a worktree
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
Clone a repository as a bare repository and initialize the worktree structure.
rustree clone [OPTIONS] <REPOSITORY_URL>
<REPOSITORY_URL>— SSH or HTTPS repository URL
-s, --ssh-key <SSH_KEY>
Path to the SSH key.
If not specified, all keys under '$HOME/.ssh' will be tried
rustree clone git@github.com:user/project.git
Or with explicit key:
rustree clone -s ~/.ssh/id_ed25519 git@github.com:user/project.git
Create and manage additional worktrees.
rustree worktree [OPTIONS] <DIRECTORY> <BRANCH>
<DIRECTORY>— Path where the worktree should be created<BRANCH>— Branch name for the new worktree
If the branch does not exist:
- It will be created
- Based on
--base-branchor the repository’s default branch
--base-branch <BASE_BRANCH>
Base branch for the new branch.
If empty, the default branch of the repository will be used
-s, --ssh-key <SSH_KEY>
Path to the SSH key.
If not specified, all keys under '$HOME/.ssh' will be tried
-
Create a new feature branch:
rustree worktree TICKET-123 TICKET-123 -
Create from specific base branch:
rustree worktree feature-x feature-x --base-branch develop
List all Git worktrees inside a repository managed by rustree.
This command scans the repository created by rustree and displays all existing worktrees in a formatted table for easy inspection.
rustree list [PATH]
[PATH]Path to the repository. If not specified, the current working directory will be used. This path can be either relative or absolute
- List worktrees in the current repository
rustree list - List worktrees in a repository
rustree list /path/to/repo
The output is presented as a structured table with the following columns:
- Name - The worktree directory name (relative to repository root folder)
- Branch name - The full Git branch name checked out in the worktree
- Path - Absolute system path to the worktree
Notes:
- Worktrees are sorted alphabetically
- Primary branches such as
mainordevelopare prioritized and shown first (if present) - Long branch names are wrapped to fit the console
rustree list
Name Branch name Path
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
main main /repository/main
develop develop /repository/develop
test-branch features/test-branch /repository/test-branch
bugfix1 bugfixes/bugfix1 /repository/bugfix1
TICKET-123 features/TICKET-123-add-custom-command-for-long-feature-branch-name /repository/TICKET-123
Remove a Git worktree managed by rustree.
This command deletes the specified worktree from disk and cleans up its Git metadata in the repository.
rustree rm-worktree <NAME> [REPO_PATH]
<NAME>- Name of the worktree to remote[REPO_PATH]- Path to the repository containing the worktree to remove. If not provided, the current directory will be used
- Remove worktree in the current repository
rustree rm-worktree name - Remove worktree in a repository
rustree rm-worktree name /path/to/repo
# Clone once
rustree clone git@github.com:user/project.git
# Work on ticket
rustree worktree TICKET-123 TICKET-123
cd TICKET-123
# hack hack hack
# Work on another ticket simultaneously
rustree worktree TICKET-456 TICKET-456
No branch switching. No stashing. No chaos.
rustree is an open source project and contributions are welcome and appreciated!
Whether you want to:
- Fix bugs
- Add new features (e.g., better remote handling, worktree management)
- Improve documentation
…your help is appreciated.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and commit:
git commit -am 'Add my feature' - Push to your fork:
git push origin feature/my-feature - Open a Pull Request
Please make sure your code follows the existing style and is well-tested.
All contributions are licensed under the same terms as rustree.