From 99f6d6f59eba1031a41d0a9ce3da47db3ce67a6b Mon Sep 17 00:00:00 2001 From: kuderr Date: Thu, 26 Feb 2026 15:20:48 +0300 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20add=20`wtbye`=20alias=20=E2=80=94?= =?UTF-8?q?=20remove=20current=20worktree=20and=20cd=20to=20origin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- aliases/git-wt.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/aliases/git-wt.sh b/aliases/git-wt.sh index 0123112..e2d38b2 100644 --- a/aliases/git-wt.sh +++ b/aliases/git-wt.sh @@ -53,6 +53,37 @@ wtco() { [[ -n "${wt_path:-}" ]] && cd "$wt_path" || return 1 } +# Remove current worktree and cd back to origin +# wtbye +wtbye() { + local origin + origin=$(git wt origin 2>/dev/null) || { echo "error: not in a git repo" >&2; return 1; } + + local cwd + cwd=$(pwd -P) + + if [[ "$cwd" == "$origin" || "$cwd" == "$origin/"* ]]; then + echo "error: already in origin repo, not in a worktree" >&2 + return 1 + fi + + local wt_home="${GIT_WT_HOME:-${HOME}/.git-wt}" + local repo_name + repo_name=$(basename "$origin") + local wt_root="${wt_home}/${repo_name}" + + if [[ "$cwd" != "${wt_root}/"* ]]; then + echo "error: not in a git-wt managed worktree" >&2 + return 1 + fi + + local wt_name="${cwd#"${wt_root}/"}" + wt_name="${wt_name%%/*}" + + cd "$origin" || return 1 + git wt rm "$wt_name" +} + # List worktrees (current repo) alias wtls='git wt list' From 6a2ebadc5a5b0070e77e425512d197aa950d0c93 Mon Sep 17 00:00:00 2001 From: kuderr Date: Thu, 26 Feb 2026 15:22:36 +0300 Subject: [PATCH 2/2] docs: add `wtbye` alias to README aliases table Co-Authored-By: Claude Opus 4.6 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3d35ee3..bed10ef 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,7 @@ source /path/to/git-wt/aliases/git-wt.sh | `wto` | `cd $(git wt origin)` | cd into the origin (main) repo | | `wtn [name]` | `git wt new` + `cd` | Create worktree and cd into it | | `wtco ` | `git wt checkout` + `cd` | Checkout existing branch and cd into it | +| `wtbye` | `git wt rm` + `cd origin` | Remove current worktree and cd to origin | | `wtls` | `git wt list` | List worktrees | | `wtla` | `git wt list-all` | List all worktrees | | `wtrm ` | `git wt rm` | Remove a worktree |