This commit is contained in:
Ahmad-Samir 2024-06-27 14:09:52 +03:00 committed by GitHub
parent c37b8955bc
commit 5c22a379d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 0 additions and 28 deletions

28
1
View File

@ -1,28 +0,0 @@
#!/bin/bash
# Prune worktree references to remove any missing worktrees
git worktree prune
# List remote branches that start with 'origin/preprod'
for branch in $(git branch -r | grep 'origin/preprod' | sed 's|origin/||'); do
# Extract the directory name without 'preprod_' prefix
dir_name=$(echo $branch | sed 's|^preprod_||')
# Create the directory if it doesn't exist
mkdir -p "../${dir_name}"
# Add the worktree
git worktree add "../${dir_name}" "origin/${branch}" || {
echo "Failed to add worktree for branch ${branch}"
continue
}
# Change to the new worktree directory and check out the branch
cd "../${dir_name}"
git checkout "${branch}" || {
echo "Failed to checkout branch ${branch} in directory ${dir_name}"
continue
}
cd - > /preprod/null
done