Delete checkout_branches_full_names.sh
This commit is contained in:
parent
68b10596de
commit
0dd52ca925
|
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Prune worktree references to remove any missing worktrees
|
||||
git worktree prune
|
||||
|
||||
# Function to add worktree and check out branch
|
||||
add_worktree_and_checkout() {
|
||||
local branch=$1
|
||||
|
||||
# Create the directory if it doesn't exist
|
||||
mkdir -p "../${branch}"
|
||||
|
||||
# Add the worktree
|
||||
git worktree add "../${branch}" "origin/${branch}" || {
|
||||
echo "Failed to add worktree for branch ${branch}"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Change to the new worktree directory and check out the branch
|
||||
cd "../${branch}"
|
||||
git checkout "${branch}" || {
|
||||
echo "Failed to checkout branch ${branch} in directory ${branch}"
|
||||
return 1
|
||||
}
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
# List remote branches that start with 'origin/dev'
|
||||
for branch in $(git branch -r | grep 'origin/dev' | sed 's|origin/||'); do
|
||||
add_worktree_and_checkout "${branch}"
|
||||
done
|
||||
|
||||
# List all branches that start with "preprod" and check out each branch into a separate directory
|
||||
for branch in $(git branch -r | grep 'origin/preprod' | sed 's|origin/||'); do
|
||||
add_worktree_and_checkout "${branch}"
|
||||
done
|
||||
|
||||
# List all branches that start with "master" and check out each branch into a separate directory
|
||||
for branch in $(git branch -r | grep 'origin/master' | grep -vE 'origin/(HEAD|master$)' | sed 's|origin/||'); do
|
||||
add_worktree_and_checkout "${branch}"
|
||||
done
|
||||
|
||||
Loading…
Reference in New Issue