Skip to content
/ wd Public

CLI tool for managing git worktrees with devcontainer support

License

Notifications You must be signed in to change notification settings

shokkunrf/wd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wd

CLI tool for managing git worktrees with devcontainer support.

A POSIX sh script that manages repositories with bare clone + git worktree. Uses a ghq-like directory layout and automates devcontainer integration.

Install

curl -fsSL https://github.com/shokkunrf/wd/releases/latest/download/install.sh | sh

Set WD_INSTALL_DIR to change the install location (default: /usr/local/bin).

Usage

wd <command> [options]

Project Management:
  clone <repo-url> [-b <branch>]    Clone repository (bare + worktree)
  list [--full-path] [--worktrees]  List managed projects

Worktree Management:
  add <branch> [-b]                 Add worktree (-b: create new branch)
  add --pr <number>                 Add PR review worktree
  remove <name>... [-b|--branch]    Remove worktree(s) and optionally branch
  remove -a [-b|--branch]           Remove all non-default worktrees
  repair                            Repair worktree relative paths

General:
  update                            Update wd to the latest version

Options:
  --version    Show version
  --help       Show this help

Environment:
  WD_ROOT    Root directory (default: ~/Repositories)

Directory structure

$WD_ROOT/
└── github.com/
    └── owner/
        └── repo/
            ├── .bare/                              # bare git database
            ├── .git                                # pointer file
            ├── .devcontainer -> main/.devcontainer  # symlink
            ├── main/                               # default worktree
            ├── wt-feature/                         # wd add
            └── pr-123/                             # wd add --pr

Tips

Add the following to .bashrc/.zshrc for convenient cd integration. Replace fzf with peco or any selector of your choice.

# Select a worktree with fzf and cd into it
wds() { dir=$(wd list | fzf) && cd "${WD_ROOT:-$HOME/Repositories}/$dir"; }

# Add a worktree and cd into it
wda() { dir=$(wd add "$@") && cd "$dir"; }

License

MIT

About

CLI tool for managing git worktrees with devcontainer support

Resources

License

Stars

Watchers

Forks