Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.2.0] - 2026-04-17

### Changed

- `git wt list` now shows only the worktree name (branch) by default, producing cleaner, script-friendly output. Pass `--path` to also display the absolute path after the name (`<name>\t<path>`).

## [1.1.0] - 2026-03-09

### Added
Expand Down Expand Up @@ -41,5 +49,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- CI workflow with ShellCheck linting and smoke tests on Ubuntu and macOS.
- Release workflow with automated GitHub Releases, Homebrew tap updates, and Scoop bucket updates.

[1.2.0]: https://github.com/silasvasconcelos/simple-git-worktreee/releases/tag/v1.2.0
[1.1.0]: https://github.com/silasvasconcelos/simple-git-worktreee/releases/tag/v1.1.0
[1.0.0]: https://github.com/silasvasconcelos/simple-git-worktreee/releases/tag/v1.0.0
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ my-project/
| Command | Description |
|---|---|
| `git wt add <branch> [base] [--go]` | Create a worktree from current branch. `--go` outputs path for `cd` |
| `git wt list` | List all worktrees |
| `git wt list [--path]` | List all worktrees (names only; `--path` also shows paths) |
| `git wt remove <branch>` | Remove a worktree |
| `git wt prune` | Clean up stale worktree references |
| `git wt path <branch>` | Print the absolute path of a worktree |
Expand Down Expand Up @@ -135,8 +135,16 @@ git wt add feature-payment main

```bash
git wt list
# /Users/you/my-project abc1234 [main]
# /Users/you/my-project/.worktrees/feature-login def5678 [feature-login]
# main
# feature-login
```

Pass `--path` to also see the absolute path of each worktree:

```bash
git wt list --path
# main /Users/you/my-project
# feature-login /Users/you/my-project/.worktrees/feature-login
```

### Get the path to open in another terminal
Expand Down
44 changes: 40 additions & 4 deletions bin/git-wt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

VERSION="1.1.0"
VERSION="1.2.0"
WORKTREE_DIR=".worktrees"
HOOKS_CONFIG=".git-wtrc"

Expand Down Expand Up @@ -136,15 +136,22 @@ EOF

usage_list() {
cat <<EOF
Usage: git wt list
Usage: git wt list [--path]

List all worktrees in the repository.

By default, only the worktree name (branch) is shown. Use --path to also
display the absolute path after the name.

Options:
--path Show the worktree path after the name

Aliases: ls

Examples:
git wt list
git wt ls
git wt list --path
EOF
}

Expand Down Expand Up @@ -250,8 +257,37 @@ cmd_add() {

cmd_list() {
wants_help "$@" && { usage_list; return 0; }

local show_path=false
for arg in "$@"; do
case "$arg" in
--path) show_path=true ;;
*) die "unknown option: $arg" ;;
esac
done

ensure_git_repo
git worktree list

git worktree list --porcelain | awk -v show_path="$show_path" '
/^worktree / { path = substr($0, 10); branch = ""; detached = 0; next }
/^branch / { branch = substr($0, 8); sub("^refs/heads/", "", branch); next }
/^detached/ { detached = 1; next }
/^$/ {
if (path != "") {
name = (branch != "") ? branch : (detached ? "(detached)" : path)
if (show_path == "true") printf "%s\t%s\n", name, path
else print name
path = ""; branch = ""; detached = 0
}
}
END {
if (path != "") {
name = (branch != "") ? branch : (detached ? "(detached)" : path)
if (show_path == "true") printf "%s\t%s\n", name, path
else print name
}
}
'
}

cmd_remove() {
Expand Down Expand Up @@ -358,7 +394,7 @@ USAGE
COMMANDS
add <branch> [base] [--go] Create a worktree in $WORKTREE_DIR/<branch>
Base defaults to current branch
list List all worktrees
list [--path] List all worktrees (--path also shows paths)
remove <branch> [-db] Remove a worktree (-db deletes branch too)
prune Remove stale worktree references
path <branch> Print the absolute path of a worktree
Expand Down
Loading