diff options
| author | Jeff Carr <[email protected]> | 2025-10-13 05:31:40 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-13 05:31:40 -0500 |
| commit | b43050d58d1ba23225386b18304a16df7c7c73c1 (patch) | |
| tree | 72e4f101fc1eddbdb3ab82a2222438feb460516e | |
| parent | 8e83f03be41ce28bbec2e40108932402792212e4 (diff) | |
git checkout --force
| -rw-r--r-- | checkout.go | 14 |
1 files 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 { |
