{"record":{"id":"ff24fc2f20914378","repo":"GoogleContainerTools/skaffold","slug":"getting-git-status-w","errorCode":null,"errorMessage":"getting git status: %w","messagePattern":"getting git status: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/tag/git_commit.go","lineNumber":76,"sourceCode":"\t\tprefix:        prefix,\n\t\trunGitFn:      runGitFn,\n\t\tignoreChanges: ignoreChanges,\n\t}, nil\n}\n\n// GenerateTag generates a tag from the git commit.\nfunc (t *GitCommit) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {\n\tref, err := t.runGitFn(ctx, image.Workspace)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to find git commit: %w\", err)\n\t}\n\n\tref = sanitizeTag(ref)\n\n\tif !t.ignoreChanges {\n\t\tchanges, err := runGit(ctx, image.Workspace, \"status\", \".\", \"--porcelain\")\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"getting git status: %w\", err)\n\t\t}\n\n\t\tif len(changes) > 0 {\n\t\t\treturn fmt.Sprintf(\"%s%s-dirty\", t.prefix, ref), nil\n\t\t}\n\t}\n\n\treturn t.prefix + ref, nil\n}\n\n// sanitizeTag takes a git tag and converts it to a docker tag by removing\n// all the characters that are not allowed by docker.\nfunc sanitizeTag(tag string) string {\n\t// Replace unsupported characters with `_`\n\tsanitized := regexp.MustCompile(`[^a-zA-Z0-9-._]`).ReplaceAllString(tag, `_`)\n\n\t// Remove leading `-`s and `.`s\n\tprefixSuffix := regexp.MustCompile(`([-.]*)(.*)`).FindStringSubmatch(sanitized)","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/tag/git_commit.go#L58-L94","documentation":"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:'.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{\"tagger\": {\"git_Commit\": {\"variant\": \"CommitSha\"}}}\n// after\n{\"tagger\": {\"git_Commit\": {\"variant\": \"CommitSha\", \"ignoreChanges\": true}}}","handlingStrategy":"try-catch","validationCode":"cmd := exec.Command(\"git\", \"-C\", workspace, \"status\", \".\", \"--porcelain\")\nif err := cmd.Run(); err != nil {\n    return fmt.Errorf(\"git status will fail in tagger: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"tag, err := tagger.GenerateTag(ctx, image)\nif err != nil && strings.Contains(err.Error(), \"getting git status\") {\n    log.Warn(\"git status failed; retrying with ignoreChanges tagger\")\n    return dirtyTolerantTagger.GenerateTag(ctx, image)\n}","preventionTips":["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"],"tags":["go","skaffold","git","tagging","permissions"],"backgroundTag":"git-status-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}