bash: rewrite gc
This commit is contained in:
parent
585b93efae
commit
75bfeb303e
1 changed files with 24 additions and 9 deletions
33
.bash_extra
33
.bash_extra
|
@ -142,19 +142,34 @@ function gcm {
|
|||
}
|
||||
function gc {
|
||||
case "$1" in
|
||||
--help)
|
||||
echo "Versuche lokalen checkout, wenn der Branch nicht vorhanden ist versuche einen checkout aus dem Remote-Repository, wenn der auch nciht vorhanden ist erstelle einen neuen Branch mit dem Namen."
|
||||
echo ""
|
||||
echo " Usage: gc <branch>"
|
||||
;;
|
||||
"")
|
||||
echo "[ERROR] Branch fehlt..."
|
||||
echo "[ERROR] Branch/Option fehlt..."
|
||||
;;
|
||||
--help | -h)
|
||||
cat <<EOF
|
||||
|
||||
Description:
|
||||
"git checkout" on steroids
|
||||
|
||||
Usage:
|
||||
gc [--help|--new-branch] <branch>
|
||||
|
||||
Options:
|
||||
-h, --help Prints this help.
|
||||
-b, --new-branch Create a new Branch instead changing to an existing branch.
|
||||
|
||||
Author:
|
||||
michael.grote@posteo.de - git.mgrote.net
|
||||
EOF
|
||||
;; --new-branch | -b)
|
||||
(git checkout --quiet -b "$2" > /dev/null 2>&1 && echo '>>> Create new branch "'"$2"'"') ||
|
||||
(git checkout --quiet "$2" > /dev/null 2>&1 && echo '>>> Branch already exists, checking out... ')
|
||||
;;
|
||||
*)
|
||||
git checkout $1 || git checkout -b $1 origin/$1 || echo ">>> Erstelle neuen Branch!" && git checkout -b $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 ">>> Unkown branch!")
|
||||
esac
|
||||
}
|
||||
function ll {
|
||||
}function ll {
|
||||
if command -v exa >/dev/null ; then
|
||||
exa --long --git --all --ignore-glob='.git' --group-directories-first --sort=name --group "$@"
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue