4 releases

0.2.0 Feb 6, 2026
0.1.2 Feb 6, 2026
0.1.1 Feb 6, 2026
0.1.0 Feb 6, 2026

#114 in Development tools

MIT license

42KB
1K SLoC

wb — git-branch interface backed by git-worktree

wb replaces the daily git branch / git checkout workflow with a worktree-based workflow. Instead of switching branches in a single working directory, each branch gets its own worktree directory.

Bare-repo directory layout

~/projects/my-project/
  .bare/                    # bare git repo
  .git                      # file: "gitdir: ./.bare"
  main/                     # worktree for main
  feature--auth/            # worktree for feature/auth

Install

From crates.io

cargo install wb

With Nix

# Run directly
nix run github:yusukeshib/wb

# Install to profile
nix profile install github:yusukeshib/wb

# Dev shell
nix develop github:yusukeshib/wb

From source

git clone https://github.com/yusukeshib/wb.git
cd wb
cargo install --path .

Shell integration

Add to your .zshrc:

eval "$(wb init zsh)"

Also supports bash and fish.

This provides:

  • A wb() shell function that handles cd into worktrees
  • Tab completions
  • wb_current_branch prompt helper

Usage

Clone a repo into bare-repo layout

wb init https://github.com/user/repo.git

Convert an existing repo

cd my-project
wb init

List branches

wb list                   # list local branches

Create a branch (+ worktree, cd into it)

wb create feature-x              # creates branch + worktree, cd's into it
wb create feature-y main         # from a specific start-point

Delete branches

wb delete feature-x              # safe delete (branch + worktree)
wb delete --force feature-x      # force delete
wb delete one two three          # delete multiple

Rename / move

wb rename new-name old-name      # rename branch + move worktree
wb rename new-name               # rename current branch

Copy

wb copy new-copy existing        # copy branch + create new worktree
wb copy new-copy                 # copy current branch

Configuration

Set via git config:

Key Default Description
wb.worktreeDir parent of .bare Base directory for worktrees
wb.naming flat Naming convention: flat (/--), nested (/ preserved), prefixed (repo-branch)

How it works

  • All branch operations go through git branch for ref management
  • Worktree operations go through git worktree add/remove/move
  • Current branch is detected by matching cwd to worktree paths (not HEAD)
  • The __wb_cd: protocol lets the binary signal the shell wrapper to cd

Dependencies

~1.2–3.5MB
~67K SLoC