-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
Hi! I’m using git gtr rm and noticed that when git worktree remove fails (e.g., index changes, untracked files), the CLI only prints a generic error:
Actual: [x] Failed to remove worktree
Expected: include Git’s reason (e.g., “contains modified or untracked files, use --force”).
Repro:
- Create a worktree:
git gtr new test-remove-reason --no-fetch --no-copy - In that worktree, make a staged change:
echo "x" >> README.md && git add README.md - Attempt removal:
git gtr rm test-remove-reason
Proposed fix:
Capture git worktree remove stderr/stdout and include it in the error message.
Patch:
diff --git a/lib/core.sh b/lib/core.sh
index 9a1a1d1..c2f0b58 100644
--- a/lib/core.sh
+++ b/lib/core.sh
@@ -423,11 +423,16 @@ remove_worktree() {
- if git worktree remove $force_flag "$worktree_path" 2>/dev/null; then
+ local remove_output
+ if remove_output=$(git worktree remove $force_flag "$worktree_path" 2>&1); then
log_info "Worktree removed: $worktree_path"
return 0
else
- log_error "Failed to remove worktree"
+ if [ -n "$remove_output" ]; then
+ log_error "Failed to remove worktree: $remove_output"
+ else
+ log_error "Failed to remove worktree"
+ fi
return 1
fi
}Environment:
- OS: macOS 26.1
- Git version: 2.52.0
- Shell: zsh
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels