Small git worktree wrapper with tmux session management
I created this tool to streamline my workflow with Codex. My typical workflow involves creating a worktree, starting Codex there in a tmux session, and then continuing to work on something else. The problem is that this workflow requires too many commands, or correctly filling three separate fields in lazygit.
Install the binary:
just install # Installs gwt to ~/bin$ gwt -h
Usage:
gwt add <worktree-name> # create new worktree and cd into it
gwt switch [worktree-name] # switch to existing worktree (or main repo if no arg)
gwt remove <worktree-name> # remove worktree at ../repo-worktree
gwt list # list all worktrees
gwt cleanup # delete dangling wt/* branches after confirmation- Branch naming: Worktrees are created with branch names in the format
wt/<name> - Directory structure: Worktrees are created as
<main-repo-parent>/<repo>-<name>alongside your main repo - Tmux integration: The
gwt addandgwt swcommands useseshto connect to tmux sessions at the worktree directory - Directory tracking: Uses
zoxideto track frequently used worktree paths - Main repo switching:
gwt swwith no arguments orgwt sw <repo-name>switches to the main repository - Smart listing:
gwt listshows worktree names and refs in two columns, excluding the main repository; detached worktrees are shown as(detached @ <commit>) - Name-based switching/removal:
gwt sw <name>andgwt rm <name>resolve against the actual Git worktree list, so detached worktrees can be managed too - Cleanup: When removing a worktree, associated tmux session is automatically killed
# Create a new worktree for feature "parsing"
gwt add parsing
# Creates branch: wt/parsing
# Creates directory: ../gwt-parsing (alongside main repo)
# Attaches to tmux session for the worktree
# List all worktrees (shows name and ref in two columns)
gwt list
# Output:
# parsing wt/parsing
# old-fix (detached @ dccfb99)
# tmp-8 wt/tmp-8
# (main repo is not shown)
# Switch to existing worktree
gwt sw parsing
# Attaches to tmux session at ../gwt-parsing
# Switch back to main repo (either works from any worktree)
gwt sw
gwt sw gwt
# Remove a worktree
gwt rm parsing
# Removes worktree and kills tmux session
# Clean up all wt/* branches
gwt cleanup
# Prompts for confirmation before deleting branchesUse just for common tasks:
$ just help
Available recipes:
build # Build the gwt binary
check # Run all checks
clean # Clean build artifacts
help # Show available commands
install # Install gwt to ~/bin along with fish autocomplete
lint # Run linters
test # Run tests