pockethost/scripts/freshen-feature-branches.sh
2024-01-16 02:20:50 -08:00

26 lines
757 B
Bash
Executable File

#!/bin/bash
# Get all branches that start with 'feat/' and store them in an array
feat_branches=($(git branch --list 'feat/*' 'fix/*' | sed 's/ //'))
# Loop through each 'feat/' branch
for branch in "${feat_branches[@]}"; do
# Checkout the 'feat/' branch
git checkout "$branch"
# Merge 'master' into the 'feat/' branch
echo "Merging 'master' into '$branch'..."
git merge master
# Check if there are merge conflicts
if [ $? -ne 0 ]; then
echo "Merge conflict detected in '$branch'. Resolve the conflict and then press Enter to continue..."
read -p ""
fi
done
# Checkout master branch or the initial branch after completing the merges
git checkout master
echo "All 'feat/' branches have been processed."