From 48ed4818f2037c9cdf3f7476dd0df35564122121 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 12 Dec 2023 12:29:40 +0100 Subject: [PATCH] git: Fix branch switch alias Fixed alias `gcb` to switch to a branch if it exists and if not create it. --- git/.config/sh/alias.d/git.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git/.config/sh/alias.d/git.sh b/git/.config/sh/alias.d/git.sh index 734f837..94df149 100644 --- a/git/.config/sh/alias.d/git.sh +++ b/git/.config/sh/alias.d/git.sh @@ -23,7 +23,9 @@ alias gcn!='git commit -v --no-edit --amend' if version_at_least 2.23 "$git_version"; then alias gcm='git switch master 2>/dev/null || git switch main' alias gcd='git switch develop 2>/dev/null || git switch staging' - alias gcb='git switch -c' + gcb() { + git switch "$@" 2>/dev/null || git switch -c "$@" + } else alias gcm='git checkout master 2>/dev/null || git checkout main' alias gcd='git checkout develop'