\o/ * \o/
| /^^^\ |
( | | | )
\|___|/
| |
/ \
/ \
"Do not be hasty."
A shell function for managing git worktrees across projects. Worktrees are stored under ~/.treebeard/<repo>/<name>, keeping them organized and out of your project directories.
- Clone or download this repository.
- Add the following line to your
~/.bashrcor~/.zshrc:
source /path/to/treebeard/treebeard- Reload your shell:
source ~/.bashrc # or source ~/.zshrcCreates a new git worktree for the current repository, checked out on a new branch named <name>.
Must be run from inside a git repository.
cd ~/projects/myrepo
treebeard new my-feature
# Created worktree at ~/.treebeard/myrepo/my-featureLists all worktrees managed by treebeard, grouped by repository.
treebeard list
# myrepo/my-feature
# myrepo/other-branch
# otherrepo/fix-bugChanges the current directory to the specified worktree.
treebeard cd myrepo/my-featureCopies a file into the specified worktree directory.
treebeard cp myrepo/my-feature ./config.jsonMoves a file into the specified worktree directory.
treebeard mv myrepo/my-feature ./config.jsonRemoves the specified worktree and deletes its associated branch.
treebeard rm myrepo/my-feature
# Removed worktree myrepo/my-featureRemoves all worktrees whose branch has already been merged into the main branch, and deletes those branches. Automatically detects main or master if no branch is specified.
treebeard prune
# Pruned myrepo/my-feature (merged into main)
treebeard prune develop
# Pruned myrepo/my-feature (merged into develop)Worktrees are stored at ~/.treebeard/<repo>/<name>. The repo name is derived automatically from the root of the current git repository. This keeps worktrees centralized and separate from the original project directories.