adding checkout_branches scripts

This commit is contained in:
gitadminexpsa 2024-06-27 03:04:57 +03:00
parent 52acf2d145
commit 281aeda22b
2 changed files with 34 additions and 0 deletions

25
checkout_branches.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# List all branches that start with "dev" and check out each branch into a separate directory
for branch in $(git branch -r | grep "origin/dev" | sed "s|origin/||"); do
# Create a new directory for each branch
mkdir "../${branch}"
# Check out the branch into the newly created directory
git worktree add "../${branch}" $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
# Create a new directory for each branch
mkdir "../${branch}"
# Check out the branch into the newly created directory
git worktree add "../${branch}" $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
# Create a new directory for each branch
mkdir "../${branch}"
# Check out the branch into the newly created directory
git worktree add "../${branch}" $branch
done

9
checkout_dev_branches.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# List all branches that start with "dev" and check out each branch into a separate directory
for branch in $(git branch -r | grep 'origin/dev' | sed 's|origin/||'); do
# Extract the directory name without 'dev_' prefix
dir_name=$(echo $branch | sed 's|^dev_||')
mkdir "../${dir_name}"
git worktree add "../${dir_name}" $branch
done