From 27a7a8a54d48c956a7a54f872b59d62366898e71 Mon Sep 17 00:00:00 2001 From: Benjamin Labrecque Date: Tue, 7 Jul 2026 11:14:52 +0200 Subject: [PATCH] cli: only delete local branch if it exists --- cli/src/core/git.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/src/core/git.py b/cli/src/core/git.py index ead099a..3cf6288 100644 --- a/cli/src/core/git.py +++ b/cli/src/core/git.py @@ -44,8 +44,9 @@ def delete_local_branch(repo: git.Repo, branch_name: str): """ Delete local branch if it already exists """ - logger.info(f"Deleting local branch '{branch_name}'...") - repo.git.branch("-D", branch_name) + if branch_name in repo.branches: + logger.info(f"Deleting local branch '{branch_name}'...") + repo.git.branch("-D", branch_name) def switch_branch(repo: git.Repo, branch_name: str):