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

View file

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