From b43050d58d1ba23225386b18304a16df7c7c73c1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 13 Oct 2025 05:31:40 -0500 Subject: git checkout --force --- checkout.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/checkout.go b/checkout.go index 05c2b6a..0331d1d 100644 --- a/checkout.go +++ b/checkout.go @@ -27,14 +27,14 @@ func (r *Repo) CheckoutForce() error { brName := r.GetDevelBranchName() if r.IsLocalBranch(brName) { log.Info(r.FullPath, "Checking out local devel") - if err := r.checkoutBranchErrorUnsafe(brName); err == nil { + if err := r.checkoutBranchForceUnsafe(brName); err == nil { return nil } } if r.IsRemoteBranch(brName) { log.Info(r.FullPath, "There is a remote devel branch") // ya, it could run this twice. whatever - if err := r.checkoutBranchErrorUnsafe(brName); err == nil { + if err := r.checkoutBranchForceUnsafe(brName); err == nil { return nil } } else { @@ -43,14 +43,14 @@ func (r *Repo) CheckoutForce() error { brName = r.GetMasterBranchName() if r.IsLocalBranch(brName) { log.Info(r.FullPath, "Checking out local master") - if err := r.checkoutBranchErrorUnsafe(brName); err == nil { + if err := r.checkoutBranchForceUnsafe(brName); err == nil { return nil } } if r.IsRemoteBranch(brName) { log.Info(r.FullPath, "Checking out remote master") // things are jacked - if err := r.checkoutBranchErrorUnsafe(brName); err == nil { + if err := r.checkoutBranchForceUnsafe(brName); err == nil { return nil } else { return err @@ -147,8 +147,10 @@ func (repo *Repo) checkoutBranchError(bName string) error { return nil } -func (repo *Repo) checkoutBranchErrorUnsafe(brName string) error { - cmd := []string{"git", "checkout", brName} +// force checkout. will delete everyhing. this is bad +// only do this when you have lost all hope +func (repo *Repo) checkoutBranchForceUnsafe(brName string) error { + cmd := []string{"git", "checkout", brName, "--force"} var err error err = repo.RunVerbose(cmd) if err != nil { -- cgit v1.2.3