Jguer/yay · error
error resetting
Error message
error resetting %s: %s
What it means
gitMerge resets the pkgbuild clone's worktree with 'git reset --hard HEAD' before fast-forward merging upstream; if that reset command fails it returns 'error resetting <dir>: <stderr>'. It means the local repo state is broken such that git could not reset (or the git binary/paths are wrong).
Solutions
- Delete the affected pkgbuilds clone and let yay re-clone it: rm -rf ~/.cache/yay/pkgbuilds (or the specific repo dir) then re-run the update.
- Read the embedded stderr: fix 'dubious ownership' with git config --global --add safe.directory <dir>, or repair the index with rm <dir>/.git/index && git -C <dir> reset --hard HEAD.
- Check free disk space and filesystem health if the reset failed with I/O errors.
- Ensure git is installed and on PATH for the user running yay.
Example fix
// before $ yay error resetting /home/u/.cache/yay/pkgbuilds/archlinux: fatal: unsafe repository // after $ git config --global --add safe.directory /home/u/.cache/yay/pkgbuilds/archlinux # or re-clone: rm -rf ~/.cache/yay/pkgbuilds && yay
Defensive patterns
Strategy: fallback
Validate before calling
// detect a broken clone before merging
if _, err := os.Stat(filepath.Join(dir, ".git")); err != nil {
os.RemoveAll(dir) // force fresh clone
}
out, err := exec.Command("git", "-C", dir, "status", "--porcelain").CombinedOutput()
if err != nil {
os.RemoveAll(dir) // repo unusable; re-clone instead of resetting
} Try / catch
if err := workdir.MergePkgbuilds(ctx, cmdBuilder, repos); err != nil {
if strings.Contains(err.Error(), "error resetting") {
os.RemoveAll(pkgbuildsDir)
return mergePkgbuilds(ctx, cmdBuilder, repos) // fresh clone
}
return err
} Prevention
- Re-clone pkgbuilds instead of repairing when git state is corrupt.
- Avoid killing yay mid git operation.
- Check safe.directory config when cache is shared across users.
- Monitor disk space before large syncs.
When it happens
Trigger: mergePkgbuilds -> gitMerge when cmdBuilder.Capture on 'git -C <dir> reset --hard HEAD' returns a non-zero exit; stderr from git is embedded in the message.
Common situations: Corrupted .git in ~/.cache/yay/pkgbuilds/<repo> after a killed update; interrupted merge leaving unresolvable index state; disk-full during a previous update; git ownership/safe.directory issues on shared caches.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/1d3dd09f40e7721a.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/sync/workdir/merge.go:17
package workdir
import (
"context"
"errors"
"github.com/leonelquinteros/gotext"
"github.com/Jguer/yay/v13/pkg/settings/exe"
)
func gitMerge(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) error {
_, stderr, err := cmdBuilder.Capture(
cmdBuilder.BuildGitCmd(ctx,
dir, "reset", "--hard", "HEAD"))
if err != nil {
return errors.New(gotext.Get("error resetting %s: %s", dir, stderr))
}
_, stderr, err = cmdBuilder.Capture(
cmdBuilder.BuildGitCmd(ctx,
dir, "merge", "--no-edit", "--ff"))
if err != nil {
return errors.New(gotext.Get("error merging %s: %s", dir, stderr))
}
return nil
}
func mergePkgbuilds(ctx context.Context, cmdBuilder exe.ICmdBuilder, pkgbuildDirs map[string]string) error {
for _, dir := range pkgbuildDirs {
err := gitMerge(ctx, cmdBuilder, dir)
if err != nil {
return err
}View on GitHub (pinned to 328f4b4939)