GoogleContainerTools/skaffold · error
getting git status: %w
Error message
getting git status: %w
What it means
After resolving the commit ref, the gitCommit Tagger (unless ignoreChanges is set) runs `git status . --porcelain` in the workspace to detect uncommitted changes and append '-dirty'. If that git status command itself fails, the error is wrapped as 'getting git status:'.
Source
Thrown at pkg/skaffold/tag/git_commit.go:76
prefix: prefix,
runGitFn: runGitFn,
ignoreChanges: ignoreChanges,
}, nil
}
// GenerateTag generates a tag from the git commit.
func (t *GitCommit) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {
ref, err := t.runGitFn(ctx, image.Workspace)
if err != nil {
return "", fmt.Errorf("unable to find git commit: %w", err)
}
ref = sanitizeTag(ref)
if !t.ignoreChanges {
changes, err := runGit(ctx, image.Workspace, "status", ".", "--porcelain")
if err != nil {
return "", fmt.Errorf("getting git status: %w", err)
}
if len(changes) > 0 {
return fmt.Sprintf("%s%s-dirty", t.prefix, ref), nil
}
}
return t.prefix + ref, nil
}
// sanitizeTag takes a git tag and converts it to a docker tag by removing
// all the characters that are not allowed by docker.
func sanitizeTag(tag string) string {
// Replace unsupported characters with `_`
sanitized := regexp.MustCompile(`[^a-zA-Z0-9-._]`).ReplaceAllString(tag, `_`)
// Remove leading `-`s and `.`s
prefixSuffix := regexp.MustCompile(`([-.]*)(.*)`).FindStringSubmatch(sanitized)View on GitHub (pinned to a1189de023)
Solutions
- Add the workspace to git's safe directory list: `git config --global --add safe.directory /path/to/workspace`
- Set ignoreChanges: true in the gitCommit tagger config if dirty-state detection is not needed
- Remove stale .git/index.lock and repair the repo (`git status` locally to confirm it works)
- Install git in the build/CI image and ensure PATH includes it
Example fix
// before
{"tagger": {"git_Commit": {"variant": "CommitSha"}}}
// after
{"tagger": {"git_Commit": {"variant": "CommitSha", "ignoreChanges": true}}} Defensive patterns
Strategy: try-catch
Validate before calling
cmd := exec.Command("git", "-C", workspace, "status", ".", "--porcelain")
if err := cmd.Run(); err != nil {
return fmt.Errorf("git status will fail in tagger: %w", err)
} Try / catch
tag, err := tagger.GenerateTag(ctx, image)
if err != nil && strings.Contains(err.Error(), "getting git status") {
log.Warn("git status failed; retrying with ignoreChanges tagger")
return dirtyTolerantTagger.GenerateTag(ctx, image)
} Prevention
- Set ignoreChanges: true when dirty-state detection isn't needed
- Add workspace to git safe.directory when running as a different user (CI root)
- Clean stale .git/index.lock files
- Keep git installed and accessible in the build image
When it happens
Trigger: GenerateTag called on a workspace where `git status` fails — e.g. the directory is inside a git repo whose ownership differs from the current user ('dubious ownership' safe.directory error), a corrupt .git index, or git missing from PATH.
Common situations: CI containers running as root against a workspace mounted/owned by another UID (Git's safe.directory protection); .git/index.lock leftovers from a crashed process; minimal images without git installed while ignoreChanges=false.
Related errors
- %q is not a valid git tagger variant
- unable to find git commit: %w
- getting tags: %w
- bad timezone provided: %q, error: %s
- parsing template: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/ff24fc2f20914378.
Report an issue: GitHub.