git-bra
brais a worktree manager that covers up the interesting parts of git with a project-aware config
It will help you:
- create or reuse worktrees by branch name
- resolve the path for your worktree branch with
bra go - run project-specific scripts after initialization
- store scripts as executable paths or inline shell text
- list worktrees and configured scripts
Current Status
The current implementation supports:
bra initbra open [branch-name]bra open --from <branch> [branch-name]bra close [branch-name]bra prunebra go <branch-name>bra listbra config pathbra config initbra config showbra script addbra script listbra script allbra script runbra script remove
Install
Build and install locally with Cargo:
This package is set up to install two binaries:
git-braso Git can dispatchgit bra ...braas the short direct command
That means both of these forms work once the package is installed:
Or run it during development with:
Config
bra reads a global config from the XDG config location:
$XDG_CONFIG_HOME/bra/config.toml- fallback:
~/.config/bra/config.toml
For tests and manual overrides, BRA_CONFIG can point to a specific config file.
Example:
= "/home/user/worktrees"
= true
= "-"
[[]]
= "bootstrap"
= "~/bin/bootstrap-my-project.sh"
[[]]
= "test-data"
= "~/bin/seed-my-project.sh"
[[]]
= "install"
= "bun install"
Config fields:
worktree_destination: base directory where worktrees are createdproject_prefix: when true, nests worktrees under<destination>/<project-alias>/branch_separator: optional replacement for/in branch namesscripts: per-project named scripts, keyed by project alias. Each script must define exactly one ofpathor non-emptytext.
Project Resolution
--project is a global option and may be passed to any command.
It accepts either:
- a project alias like
my-project - a path to an existing cloned repository
If --project is omitted, bra tries to infer the project from the current Git repository.
The default alias is taken from the last part of the origin URL:
git@github.com:some-org/my-project.git->my-project
Usage
Create or reuse a worktree for a branch:
When no branch is provided, bra open creates a new branch from the current branch using <current-branch>-YYMMDD-HHMMSS-nnnnnnnnn in UTC.
Create a worktree from a specific base branch instead of the current branch:
Remove a worktree by branch name, optionally deleting the local branch:
Prune stale worktree metadata. Branch cleanup is explicit: --merged also deletes local branches already merged into the current HEAD.
Initialize the current repository or worktree:
Print the path for a branch:
List worktrees for the current repository:
Manage scripts:
|
Path scripts are executed directly. Inline scripts are executed through $SHELL -c, falling back to /bin/sh when SHELL is not set. Passing --text without a value reads the inline script from stdin.
Run a script directly using the external command shortcut:
Unknown subcommands are treated as script names and forwarded to script run with any additional arguments.
Inspect config:
bra config init creates the config file with commented defaults. The config file is still created automatically the first time a command saves configuration, such as bra script add.
Run a command for another project explicitly:
Shell Integration
bra go prints only the resolved path, so shell wrappers stay simple.
Example for bash or zsh:
If you also want a helper that creates or reuses the worktree and then enters it:
Example usage:
Command Notes
bra initrefuses to reset if the target repository has uncommitted changesbra initfetchesoriginand hard-resets toorigin/<branch>when that remote branch existsbra open [branch]creates the worktree if needed, runs the init flow there, and prints the final path. Withoutbranch, it generates one from the current branch and timestamp.bra open --from <branch> [branch]creates new branches from the selected local ororigin/<branch>base instead ofHEAD.bra close [branch]removes the worktree for a branch. It only deletes the local branch when--delete-branchis passed.bra prunerunsgit worktree prune. Branch deletion is opt-in through--merged.bra go <branch>prints the parent repository path when that branch is currently checked out in the primary worktree; otherwise it prints the configured worktree pathbra script add <name> <path>stores a path-based scriptbra script add <name> --text [text]stores an inline script, reading from stdin whentextis omittedbra script run <name> -- <args>runs the configured script in the repository or worktree directory and forwards trailing arguments
Development
Run tests with:
The repository also includes integration tests that create temporary Git repositories and exercise real worktree flows.