Skip to content

devmobasa/treeist

Repository files navigation

treeist

treeist is a Git worktree helper.

The project/package name is Treeist, and the command you run is wt.

What it does

  • Creates or reuses worktrees from branch names.
  • Optionally auto-switches your shell directory after command execution.
  • Supports interactive TUI pickers for switching and cleanup.
  • Supports global/project config, environment overrides, and CLI overrides.

Requirements

  • .NET 10 SDK
  • Git

Install

Install/Update as a global .NET tool from this repo

./install-global-tool.sh

After install, run:

wt --help

Run without installing (development)

dotnet run --project src/Treeist.Cli -- --help

Quick Start

1. Enable shell integration (bash/zsh)

Add this to your shell config (~/.bashrc or ~/.zshrc):

eval "$(wt init zsh)"

This allows wt to print the target directory and have your shell function cd there.

To disable auto-switch behavior:

eval "$(wt init zsh --no-switch-directory)"

Or set:

export TREEIST_NO_SWITCH_DIRECTORY=1

2. Create/switch worktrees

wt                 # list worktrees
wt <branch>        # create or switch to branch worktree
wt switch          # open switch picker
wt cleanup         # open cleanup picker

Command Reference

Root command

wt [branch] [options]

Global options:

  • --dir <dir>: target directory for a new worktree.
  • --from <ref>: base branch/commit when creating a new branch.
  • --branch-prefix <prefix>: prefix template for branch names.
  • --copyignored: copy ignored files into newly created worktree.
  • --copyuntracked: copy untracked files into newly created worktree.
  • --copymodified: copy modified files into newly created worktree.
  • --nocopy <pattern...>: glob patterns to skip while copying.

Subcommands

  • wt ls (list, ll): list worktrees.
  • wt switch [branch]: switch/create a worktree (opens TUI when branch omitted).
  • wt cleanup [worktrees...] [--mode interactive|merged|remoteless|all] [--dry-run] [--force] [-y|--yes]
  • wt init <bash|zsh> [--no-switch-directory]

Configuration

Configuration precedence (lowest to highest):

  1. Built-in defaults
  2. Global config file
  3. Project config file
  4. Environment variables
  5. CLI options

Config file locations

  • Linux: ~/.config/treeist/config.toml (or $XDG_CONFIG_HOME/treeist/config.toml)
  • macOS: ~/Library/Application Support/treeist/config.toml
  • Windows: %APPDATA%\\treeist\\config.toml
  • Project local: <repo>/.treeist.toml

Example .treeist.toml

[worktree]
# Default: "../{repo_name}-worktrees/{branch}"
directory_pattern = "../{repo_name}-worktrees/{branch}"
branch_prefix = ""
auto_fetch = true

[copy]
copyignored = false
copyuntracked = false
copymodified = false
nocopy = [".env*", "*.local"]

[cleanup]
# interactive | merged | remoteless | all
default_mode = "interactive"

Template tokens

  • {repo_dir}: absolute repo root path
  • {repo_name}: repo directory name
  • {repo_parent_dir}: parent directory of repo root
  • {branch}: normalized branch segment (/, \\, spaces, _ -> -, lowercase)

Environment variables

  • TREEIST_WORKTREE_DIRECTORY_PATTERN
  • TREEIST_WORKTREE_BRANCH_PREFIX
  • TREEIST_WORKTREE_AUTO_FETCH
  • TREEIST_COPY_COPYIGNORED
  • TREEIST_COPY_COPYUNTRACKED
  • TREEIST_COPY_COPYMODIFIED
  • TREEIST_COPY_NOCOPY
  • TREEIST_CLEANUP_DEFAULT_MODE
  • TREEIST_TERMINAL_MODE
  • TREEIST_TERMINAL_ALWAYS_NEW
  • TREEIST_TERMINAL_PROGRAM
  • TREEIST_NO_SWITCH_DIRECTORY

Development

dotnet restore treeist.sln
dotnet build treeist.sln
dotnet test treeist.sln
dotnet pack src/Treeist.Cli -c Release

About

Git worktree helper CLI (wt)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published