From b6c31baa33717b220cf5bd8c13d7e503f96cb671 Mon Sep 17 00:00:00 2001 From: janezlapajne Date: Sat, 6 Jul 2024 18:18:55 +0200 Subject: [PATCH] refactor: Update branches script to improve branch management --- scripts/update-branches.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 scripts/update-branches.sh diff --git a/scripts/update-branches.sh b/scripts/update-branches.sh new file mode 100755 index 0000000..f9976fe --- /dev/null +++ b/scripts/update-branches.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e +set -x + +# Save the current branch name +current_branch=$(git branch --show-current) + +# Update main +git checkout main +git pull origin main + +# Update develop +git checkout develop +git pull origin develop +git rebase main +git push + +# Switch back to the original branch +git checkout "$current_branch" + +# If the current branch is not main or develop, rebase it onto develop +if [[ "$current_branch" != "main" && "$current_branch" != "develop" ]]; then + git rebase develop +fi + +echo "Branches have been updated and rebased accordingly."