GoogleContainerTools/skaffold · critical

no 'git' program on path: %w

Error message

no 'git' program on path: %w

What it means

gitCmd.Run wraps every git invocation, and before exec'ing anything it calls findGit() to locate the git executable on PATH. If no `git` binary is found, this error is returned for every git operation, so the root cause is an environment problem, not a git command failure.

Source

Thrown at pkg/skaffold/git/gitutil.go:189

		if _, err := r.Run(ctx, "reset", "--hard", fmt.Sprintf("origin/%s", ref)); err != nil {
			return "", fmt.Errorf("failed to clone repo %s: trouble resetting branch to origin/%s; run 'git clone <REPO>; stat <DIR/SUBDIR>' to verify credentials: %w", g.Repo, ref, err)
		}
	}
	return repoCacheDir, nil
}

// gitCmd runs git commands in a git repo.
type gitCmd struct {
	// Dir is the directory the commands are run in.
	Dir string
}

// Run runs a git command.
// Omit the 'git' part of the command.
func (g *gitCmd) Run(ctx context.Context, args ...string) ([]byte, error) {
	p, err := findGit()
	if err != nil {
		return nil, fmt.Errorf("no 'git' program on path: %w", err)
	}

	cmd := exec.Command(p, args...)
	cmd.Dir = g.Dir
	return util.RunCmdOut(ctx, cmd)
}

func tryUpdateRemoteOriginFetchURL(ctx context.Context, r gitCmd, newFetchURI string) {
	output, err := r.Run(ctx, "remote", "get-url", "origin")
	if err != nil {
		log.Entry(ctx).Debugf("failed to get remote origin fetch URI: %v", err)
		return
	}

	currentFetchURI := strings.TrimSpace(string(output))
	if currentFetchURI == newFetchURI {
		return
	}

View on GitHub (pinned to a1189de023)

Solutions

  1. Install git in the environment/container running Skaffold (e.g. `apk add git`, `apt-get install -y git`).
  2. Verify with `which git` in the same shell/container where Skaffold runs.
  3. If git is installed in a nonstandard location, extend PATH before launching Skaffold.
  4. Use a base image that includes git (e.g. a full debian/alpine image instead of distroless/scratch).

Example fix

// before (Dockerfile)
FROM gcr.io/distroless/static
// after
FROM alpine:3.19
RUN apk add --no-cache git
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath("git"); err != nil {
	return fmt.Errorf("git is required but not found on PATH: %w", err)
}

Prevention

When it happens

Trigger: Any call to gitCmd.Run (invoked by syncRepo, tryUpdateRemoteOriginFetchURL, and every git-based remote dependency sync) when findGit() cannot locate `git` in the PATH of the process running Skaffold.

Common situations: Minimal Docker/CI images (distroless, alpine without git, scratch) that don't ship git; PATH not set in the container or systemd service running Skaffold; git removed from a slimmed-down builder image.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/cb71c0bad12dd081. Report an issue: GitHub.