revert bash: gc: set default branch programatically

Signed-off-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2023-12-21 13:27:09 +01:00
parent 076d658aa8
commit 9dc37c67cc
1 changed files with 4 additions and 4 deletions

View File

@ -150,11 +150,11 @@ EOF
*)
if [ ! -z $1 ] ; then
(echo ">>> Try local checkout" && git checkout --quiet "$1" > /dev/null 2>&1) ||
(echo ">>> Try remote checkout" && git checkout --quiet -b "$1" origin/"$1" > /dev/null 2>&1 || echo ">>> Unknown branch!")
(echo ">>> Try remote checkout" && git checkout --quiet -b "$1" origin/"$1" > /dev/null 2>&1 || echo ">>> Unkown branch!")
else
echo ">>> get default branch"
default_branch=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
git checkout --quiet ${default_branch} > /dev/null 2>&1
(git checkout --quiet master > /dev/null 2>&1 && echo '>>> Try checking out master') ||
(git checkout --quiet main > /dev/null 2>&1 && echo '>>> Try checking out main') ||
(git checkout --quiet release > /dev/null 2>&1 && echo '>>> Try checking out release')
fi
esac
}