From 281aeda22bb8c51be956e5917eb107ba371bd204 Mon Sep 17 00:00:00 2001 From: gitadminexpsa Date: Thu, 27 Jun 2024 03:04:57 +0300 Subject: [PATCH] adding checkout_branches scripts --- checkout_branches.sh | 25 +++++++++++++++++++++++++ checkout_dev_branches.sh | 9 +++++++++ 2 files changed, 34 insertions(+) create mode 100755 checkout_branches.sh create mode 100755 checkout_dev_branches.sh diff --git a/checkout_branches.sh b/checkout_branches.sh new file mode 100755 index 000000000..ab30773d1 --- /dev/null +++ b/checkout_branches.sh @@ -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 diff --git a/checkout_dev_branches.sh b/checkout_dev_branches.sh new file mode 100755 index 000000000..9b4dbb51e --- /dev/null +++ b/checkout_dev_branches.sh @@ -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