{"record":{"id":"cde755bd040806a1","repo":"JanDeDobbeleer/oh-my-posh","slug":"git-config-file-not-found","errorCode":null,"errorMessage":"git config file not found","messagePattern":"git config file not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/git.go","lineNumber":751,"sourceCode":"\tsection := cfg.Section(sectionName)\n\tpushRemote := section.Key(\"pushRemote\").String()\n\tif pushRemote == \"\" {\n\t\tpushRemote = cfg.Section(\"remote\").Key(\"pushDefault\").String()\n\t}\n\n\tif pushRemote == \"\" {\n\t\tpushRemote = upstream\n\t}\n\n\treturn pushRemote + \"/\" + branch\n}\n\nfunc (g *Git) getGitConfig() (*ini.File, error) {\n\tg.configOnce.Do(func() {\n\t\tconfigData := g.fileContent(g.mainSCMDir, \"config\")\n\t\tif configData == \"\" {\n\t\t\tlog.Debug(\"git config file not found\")\n\t\t\tg.configErr = fmt.Errorf(\"git config file not found\")\n\t\t\treturn\n\t\t}\n\n\t\tcfg, err := ini.Load(configData)\n\t\tif err != nil {\n\t\t\tg.configErr = err\n\t\t\treturn\n\t\t}\n\n\t\tg.config = cfg\n\t})\n\n\treturn g.config, g.configErr\n}\n\nfunc (g *Git) cleanUpstreamURL(url string) string {\n\t// Azure DevOps\n\tif strings.Contains(url, \"dev.azure.com\") {","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/git.go#L733-L769","documentation":"getGitConfig lazily loads the current repository's .git/config file with a sync.Once. If g.fileContent returns an empty string (file missing or unreadable), it caches and returns the sentinel error \"git config file not found\". This typically means the segment isn't operating inside a valid git worktree or the config file can't be read.","triggerScenarios":"The git segment (fetch/Enabled path) queries config values while mainSCMDir points to a directory without a readable \"config\" file - e.g. not in a repo, a bare/partial clone layout change, or permission problems reading .git/config.","commonSituations":"Prompt rendered outside any git repository; .git directory deleted or renamed; running as a user without read access to the repo; a broken .git file (worktree pointer) so mainSCMDir resolves to a nonexistent path.","solutions":["cd into a valid git repository (verify .git/config exists) - the segment is meant for repos.","Check that the repo's .git/config file is readable by the user running the shell (permissions).","If using a worktree/submodule, verify the .git pointer file resolves to a real git dir containing config.","Because the result is cached in configErr via sync.Once, restart the shell if you fixed the repo mid-session so the segment re-reads config."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Before enabling the git segment, confirm a repo is present\nif _, err := os.Stat(filepath.Join(cwd, \".git\")); os.IsNotExist(err) {\n    // not a git repo: disable segment\n}","typeGuard":null,"tryCatchPattern":"cfg, err := gitSegment.getGitConfig()\nif err != nil && err.Error() == \"git config file not found\" {\n    // not in a repo (or unreadable config): fall back to non-git prompt\n    return defaultPrompt\n}","preventionTips":["Only render git segments inside repositories (oh-my-posh does this via Enabled, but check custom templates)","Ensure the running user can read .git/config","Fix worktree/submodule .git pointer files if they dangle","Restart the shell after repairing a repo - the config error is cached per session via sync.Once"],"tags":["git","config","segments","file-not-found"],"backgroundTag":"git-config-missing","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}