From 6f9bfec60f0b067ef757390a7efff1d9d94bcaf7 Mon Sep 17 00:00:00 2001 From: Dustin Smith Date: Mon, 19 Jan 2026 20:54:40 +0700 Subject: [PATCH] fix: install pre-checkout hook in gt git-init The hook was only installed via 'gt install --git' but not when running 'gt git-init' separately. --- internal/cmd/gitinit.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/cmd/gitinit.go b/internal/cmd/gitinit.go index 48e4be7f..2a13b43f 100644 --- a/internal/cmd/gitinit.go +++ b/internal/cmd/gitinit.go @@ -138,6 +138,11 @@ func runGitInit(cmd *cobra.Command, args []string) error { fmt.Printf(" ✓ Git repository already exists\n") } + // Install pre-checkout hook to prevent accidental branch switches + if err := InstallPreCheckoutHook(hqRoot); err != nil { + fmt.Printf(" %s Could not install pre-checkout hook: %v\n", style.Dim.Render("⚠"), err) + } + // Create GitHub repo if requested if gitInitGitHub != "" { if err := createGitHubRepo(hqRoot, gitInitGitHub, !gitInitPublic); err != nil {