gc: tuning

This commit is contained in:
Michael Grote 2022-11-30 13:50:25 +01:00
parent fe2c85500e
commit 94f4bebf25

View file

@ -157,9 +157,6 @@ function gcm {
}
function gc {
case "$1" in
"")
echo "[ERROR] Branch/Option fehlt..."
;;
--help | -h)
cat <<EOF
@ -167,10 +164,10 @@ Description:
"git checkout" on steroids
Usage:
gc [--help|--new-branch] <branch>
gc [--help|--new-branch] [branch]
Options:
-h, --help Prints this help.
-h, --help Print this help.
-b, --new-branch Create a new Branch instead changing to an existing branch.
Author:
@ -182,8 +179,14 @@ EOF
(git checkout --quiet "$2" > /dev/null 2>&1 && echo '>>> Branch already exists, checking out... ')
;;
*)
(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 ">>> Unkown branch!")
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 ">>> Unkown branch!")
else
(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
}
function gsp {