{"record":{"id":"3414c11a8273029e","repo":"asdf-vm/asdf","slug":"unable-to-resolve-plugin-new-git-head-w","errorCode":null,"errorMessage":"unable to resolve plugin new Git HEAD: %w","messagePattern":"unable to resolve plugin new Git HEAD: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/git/git.go","lineNumber":132,"sourceCode":"\tcommonOpts := []string{\"git\", \"-C\", r.Directory}\n\n\trefSpec := fmt.Sprintf(\"+%s:%s\", shortRef, shortRef)\n\tcmdStr := append(commonOpts, []string{\"fetch\", \"--prune\", \"--update-head-ok\", remoteName, refSpec}...)\n\n\t_, stderr, err := exec(cmdStr)\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", errors.New(stdErrToErrMsg(stderr))\n\t}\n\n\tcmdStr = append(commonOpts, []string{\"-c\", \"advice.detachedHead=false\", \"checkout\", \"--force\", shortRef}...)\n\t_, stderr, err = exec(cmdStr)\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", errors.New(stdErrToErrMsg(stderr))\n\t}\n\n\tnewHash, err := r.Head()\n\tif err != nil {\n\t\treturn ref, oldHash, newHash, fmt.Errorf(\"unable to resolve plugin new Git HEAD: %w\", err)\n\t}\n\treturn ref, oldHash, newHash, nil\n}\n\nfunc (r Repo) defaultRemote() (string, error) {\n\tstdout, _, err := exec([]string{\"git\", \"-C\", r.Directory, \"remote\"})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn strings.SplitN(stdout, \"\\n\", 2)[0], nil\n}\n\nfunc (r Repo) remoteDefaultBranch() (string, error) {\n\tremote, err := r.defaultRemote()\n\tif err != nil {\n\t\treturn \"\", err\n\t}","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/asdf-vm/asdf/blob/074a1722ca88d6677f228541ce06efaf4f9924d4/internal/git/git.go#L114-L150","documentation":"After fetching in git.Update, the code resolves the repository's new HEAD via r.Head() to report the updated ref. If resolving that HEAD fails, Update returns \"unable to resolve plugin new Git HEAD\" wrapping the underlying git error, aborting the version reporting.","triggerScenarios":"`asdf update` or `asdf plugin update <plugin>` when the fetch succeeded but `git rev-parse HEAD` fails — e.g. repo has no commits on the checked-out branch, corrupted .git directory, or the checked-out ref points to nothing after a failed fetch.","commonSituations":"Interrupted updates leaving a corrupt plugin repo; upstream force-push removing the tracked ref; disk-full or permission issues corrupting .git.","solutions":["Re-clone the plugin: `asdf plugin remove <plugin>` then `asdf plugin add <plugin> <url>`.","Run `git -C ~/.asdf/plugins/<plugin> fsck` / `git status` to diagnose corruption.","Retry `asdf plugin update <plugin>` after fixing disk/permission problems.","Check the remote branch still exists; if force-pushed, reset the local repo or re-add."],"exampleFix":"# before\nasdf plugin update nodejs   # corrupt repo\n# after\nasdf plugin remove nodejs\nasdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git","handlingStrategy":"fallback","validationCode":"git -C ~/.asdf/plugins/\"$PLUGIN\" status --porcelain >/dev/null 2>&1 || { echo \"repo corrupt, re-add plugin\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! asdf plugin update \"$PLUGIN\"; then\n  asdf plugin remove \"$PLUGIN\" && asdf plugin add \"$PLUGIN\" \"$URL\"\nfi","preventionTips":["Avoid interrupting asdf plugin update mid-run","Re-add plugins whose upstream force-pushed branches","Monitor disk space to prevent .git corruption","Run `git fsck` on plugin repos when updates misbehave"],"tags":["git","plugins","update","head-resolution"],"backgroundTag":"git-head-resolution-failed","analyzedSha":"074a1722ca88d6677f228541ce06efaf4f9924d4","analyzedAt":"2026-08-30T19:56:42.972Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}