git-wt

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 4 Imported by: 0

README

git-wt

git-wt manages Git worktrees using a consistent naming convention.

Managed worktrees are stored next to the main repository using this path format:

<repo>.<normalized-branch-name>

Example:

  • repo: my-repo
  • branch: feature/login
  • worktree path: ../my-repo.feature.login

Installation

Install using Go,

go install github.com/nnutter/git-wt@latest

Commands

git-wt create <name>

Create a managed worktree for a branch.

  • If the branch already exists, the worktree is created from that branch.
  • If the branch does not exist, it is created from the upstream branch; which defaults to the default origin branch but can be set explicity with --upstream | -u.

Example:

git-wt create feature/login
git-wt create -u origin/v1.2 hotfix/1.2.1
git-wt list

List managed worktrees in a table.

Columns:

  • Name: branch name
  • Path: relative worktree path
  • Status: first line of git status -sb
  • Dirty: whether the worktree has uncommitted changes
git-wt migrate

Bring existing branch worktrees under git-wt management.

  • Creates managed worktrees for local branches that do not already have one.
  • Renames existing non-managed branch worktrees into the managed path format.

Use --prompt | -p to review the proposed migrations before applying them.

Example:

git-wt migrate
git-wt migrate --prompt
git-wt prune

Remove managed worktrees that are both clean, no uncommitted changes, and merged into their upstream branch.

Use --prompt | -p to choose which worktrees to prune interactively.

git-wt remove <name>

Remove a managed worktree and delete its branch.

It refuses to remove dirty or unmerged worktrees by default. Use --force | -f to force (destructive) removal.

Example:

git-wt remove feature/login
git-wt remove --force feature/login

Typical Flow

Checkout git-cd to generate shell functions to easily cd to worktrees.

Create a shell function, nn, to switch between the repos under my GitHub path,

git-cd --name nn --repos ~/src/github.com/nnutter

Then a typical flow might look like,

nn some-repo
git-wt create feature/login
...
nn some-repo.feature.login
nn some-repo
git-wt prune

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL