Delete checkout_master_branches_Extracted_names.sh
This commit is contained in:
parent
a7f721ab0b
commit
c1087f15e4
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Prune worktree references to remove any missing worktrees
|
||||
git worktree prune
|
||||
|
||||
# List remote branches that start with 'origin/master'
|
||||
for branch in $(git branch -r | grep 'origin/master' | grep -vE 'origin/(HEAD|master$)' | sed 's|origin/||'); do
|
||||
# Extract the directory name without 'master_' prefix
|
||||
dir_name=$(echo $branch | sed 's|^master_||')
|
||||
|
||||
# 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 - > /dev/null
|
||||
done
|
||||
Loading…
Reference in New Issue