Fix: create branch when checking non origin remote (#430)

This commit is contained in:
sandr01d 2025-04-22 18:08:37 +02:00 committed by GitHub
parent 8c0355ca9e
commit 79c4e5a4c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -849,10 +849,10 @@ _forgit_checkout_branch() {
[[ -z "$branch" ]] && return 1
# track the remote branch if possible
if [[ "$branch" == "remotes/origin/"* ]]; then
if git branch | grep -qw "${branch#remotes/origin/}"; then
if [[ "$branch" == "remotes/"* ]]; then
if git branch | grep -qw "${branch#remotes/*/}"; then
# hack to force creating a new branch which tracks the remote if a local branch already exists
_forgit_git_checkout_branch -b "track/${branch#remotes/origin/}" --track "$branch"
_forgit_git_checkout_branch -b "track/${branch#remotes/*/}" --track "$branch"
elif ! _forgit_git_checkout_branch --track "$branch" 2>/dev/null; then
_forgit_git_checkout_branch "$branch"
fi