bra

A git worktree manager with project-aware configuration.

Worktrees by branch name, setup scripts per project.

Git toolsCLIRustv0.4.0, MIT

The problem

git worktree works, but every new worktree needs a path picked, a branch created and the project bootstrapped again: dependencies installed, test data seeded. bra covers up those interesting parts of git. You name a branch, and it creates or reuses the worktree, runs the project's scripts there and prints the path.

bra open feature/sso
bra open --from develop feature/sso
bra close feature/sso --delete-branch
bra prune --merged

bra open with no branch creates one from the current branch, named <current-branch>-YYMMDD-HHMMSS-nnnnnnnnn in UTC. The package installs two binaries, bra and git-bra, so git bra list works too.

How it works

One global config at $XDG_CONFIG_HOME/bra/config.toml sets where worktrees go and holds named scripts for each project:

worktree_destination = "/home/user/worktrees"
project_prefix = true
branch_separator = "-"

[[scripts.my-project]]
name = "install"
text = "bun install"

The project alias comes from the last part of the origin URL, or from --project with an alias or a path to a clone. A script is either an executable path or inline text run through $SHELL -c. Any subcommand bra does not recognise is treated as a script name, so bra build --release runs the build script with --release appended.

bra init fetches origin and hard-resets to origin/<branch> when that branch exists. It refuses to do so if the repository has uncommitted changes. Deleting branches is always opt-in: --delete-branch on close, --merged on prune.

Shell integration

bra go prints only the path, so cd stays a one-liner:

brag() {
  cd "$(bra go "$@")"
}

bra go returns the parent repository path when the branch is checked out in the primary worktree. The integration tests create temporary git repositories and run real worktree flows against them.