Add ability to checkout existing branch with gcb in fish (#232)

This commit is contained in:
Chris Apple 2022-08-16 09:56:33 -07:00 committed by GitHub
parent bdef69083c
commit 3f50933f04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -304,7 +304,11 @@ function forgit::checkout::branch -d "git checkout branch selector" --argument-n
forgit::inside_work_tree || return 1
if test -n "$input_branch_name"
git checkout -b "$input_branch_name"
if git branch --list | grep "$input_branch_name" > /dev/null
git switch "$input_branch_name"
else
git switch -c "$input_branch_name"
end
set checkout_status $status
git status --short
return $checkout_status