From d4b4ce39087a2dfe4812d54de7a9865fb2ba9855 Mon Sep 17 00:00:00 2001 From: Chris Apple Date: Tue, 16 Aug 2022 09:52:51 -0700 Subject: [PATCH] Add ability to checkout existing branch with gcb --- conf.d/forgit.plugin.fish | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf.d/forgit.plugin.fish b/conf.d/forgit.plugin.fish index c9fefd0..fd003d8 100644 --- a/conf.d/forgit.plugin.fish +++ b/conf.d/forgit.plugin.fish @@ -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