From d98f532dc6506c25e23d46cf10a8cf82f59ef545 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Sun, 11 Jan 2026 01:10:27 +0100 Subject: [PATCH] feat(git): add create and checkout branch as new gitf case --- .bash_aliases | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index 9b7e9a4..870b977 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -162,18 +162,33 @@ gitf () { gitf ;; - # Checkout [and create] a git branch (defaults to "master") + # Checkout a git branch (defaults to "master") "b") local branch="${2:-master}" - if git show-ref --verify --quiet refs/heads/"$branch"; then - git checkout $branch + if ! git show-ref --verify --quiet refs/heads/"$branch"; then gitf + echo "" + echo -e "\e[0;91mNo such branch '$branch'\e[0m" + return 0 + fi + + git checkout $branch + gitf + ;; + + # Checkout [and create] a git branch (defaults to "master") + "cb") + local branch="${2:-master}" + + # Checkout existing branch + if git show-ref --verify --quiet refs/heads/"$branch"; then + gitf b $branch return 0 fi git checkout -b $branch - gitf + gitf b $branch ;; # Pull current branch from a remote (defaults to "origin"). "d" for download.