feat(git): add create and checkout branch as new gitf cb case (#102)

Reviewed-on: https://codeberg.org/vlw/dotfiles/pulls/102
This commit is contained in:
Victor Westerlund 2026-01-11 01:11:48 +01:00
parent 39f4227c06
commit ae3b0ec4e8

View file

@ -162,18 +162,33 @@ gitf () {
gitf gitf
;; ;;
# Checkout [and create] a git branch (defaults to "master") # Checkout a git branch (defaults to "master")
"b") "b")
local branch="${2:-master}" local branch="${2:-master}"
if git show-ref --verify --quiet refs/heads/"$branch"; then if ! git show-ref --verify --quiet refs/heads/"$branch"; then
git checkout $branch
gitf 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 return 0
fi fi
git checkout -b $branch git checkout -b $branch
gitf gitf b $branch
;; ;;
# Pull current branch from a remote (defaults to "origin"). "d" for download. # Pull current branch from a remote (defaults to "origin"). "d" for download.