From fd19eb9fb8e20b44b5b78f6f0b72d49190ad6c46 Mon Sep 17 00:00:00 2001 From: Konboi Date: Wed, 8 May 2024 17:09:14 +0900 Subject: [PATCH] updated to checkout parent branch instead of switch to detached HEAD --- internal/actions/sync_stack.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/actions/sync_stack.go b/internal/actions/sync_stack.go index 370d22e6..5ec85b5c 100644 --- a/internal/actions/sync_stack.go +++ b/internal/actions/sync_stack.go @@ -190,8 +190,9 @@ func SyncStack(ctx context.Context, " - deleting merged branch ", colors.UserInput(currentBranch), "\n", ) - if _, err := repo.Git("switch", "--detach"); err != nil { - return errors.Errorf("cannot switch to detached HEAD: %v", err) + + if _, err := repo.CheckoutBranch(&git.CheckoutBranch{Name: br.Parent.Name}); err != nil { + return errors.Errorf("cannot checkout to parent branch %s: %v", br.Parent.Name, err) } if _, err := repo.Git("branch", "-D", currentBranch); err != nil { return errors.Errorf("cannot delete merged branch %q: %v", currentBranch, err)