-
Notifications
You must be signed in to change notification settings - Fork 815
Closed
Description
Steps to Reproduce
- git clone --depth 1 https://git.rancher.io/charts --branch dev-v2.8 using Git CLI
- and then run the following Golang script
openOptions := git.PlainOpenOptions{
DetectDotGit: false,
}
// git clone --depth 1 https://git.rancher.io/charts --branch dev-v2.8
repo, err := git.PlainOpenWithOptions("/Users/RSAKALA/temp/charts", &openOptions)
if err != nil {
fmt.Println(err)
return
}
// Ensure
// Hard Reset to commit
resetOpts := git.ResetOptions{
Mode: git.HardReset,
}
resetOpts.Commit = plumbing.NewHash("6a2b15c6f6487b4db16f10d8ec69bb8bf91dcabd")
// Validate hashCommit and reset options
err = resetOpts.Validate(repo)
if err != nil {
fmt.Println("hardReset validation failure: %w", err)
}
// Open new worktree
wt, err := repo.Worktree()
if err != nil {
fmt.Println("hardReset failure on WorkTree: %w", err)
}
// Reset
err = wt.Reset(&resetOpts)
if err != nil {
fmt.Println("hardReset failure: %w", err)
} else {
fmt.Println("Hard Reset Worked")
return
}
- Run
git log
Output
fatal: bad object HEAD
Metadata
Metadata
Assignees
Labels
No labels