forked from CodebuffAI/codebuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup-worktree.sh
More file actions
executable file
·40 lines (31 loc) · 1.04 KB
/
Copy pathcleanup-worktree.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Script to clean up a git worktree
# Usage: ./scripts/cleanup-worktree.sh <worktree-name>
set -e
# Check if worktree name is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <worktree-name>"
echo "Example: $0 feature-branch"
exit 1
fi
WORKTREE_NAME="$1"
WORKTREES_DIR="../codebuff-worktrees"
WORKTREE_PATH="$WORKTREES_DIR/$WORKTREE_NAME"
echo "Cleaning up worktree: $WORKTREE_NAME"
# Check if worktree exists in git worktree list
if git worktree list | grep -q "$WORKTREE_PATH"; then
echo "Removing git worktree..."
git worktree remove "$WORKTREE_PATH" --force
else
echo "⚠️ Worktree '$WORKTREE_NAME' not found in git worktree list (may already be removed)"
fi
# Clean up any worktree-specific files that might be left behind
if [ -f "$WORKTREE_PATH/.env.worktree" ]; then
rm -f "$WORKTREE_PATH/.env.worktree"
fi
# Clean up any remaining files
if [ -d "$WORKTREE_PATH" ]; then
echo "Cleaning up remaining files..."
rm -rf "$WORKTREE_PATH"
fi
echo "✅ Worktree '$WORKTREE_NAME' cleaned up successfully!"