{"record":{"id":"cf762bc765d45db1","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-unset-git-configuration-entry-name","errorCode":null,"errorMessage":"Failed to unset Git configuration entry '{name}'","messagePattern":"Failed to unset Git configuration entry '(.+?)'","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GitConfiguration.cs","lineNumber":643,"sourceCode":"        public void Unset(GitConfigurationLevel level, string name)\n        {\n            EnsureSpecificLevel(level);\n\n            string levelArg = GetLevelFilterArg(level);\n            using (ChildProcess git = _git.CreateProcess($\"config {levelArg} --unset {QuoteCmdArg(name)}\"))\n            {\n                git.Start(Trace2ProcessClass.Git);\n                git.WaitForExit();\n\n                switch (git.ExitCode)\n                {\n                    case 0: // OK\n                    case 5: // Trying to unset a value that does not exist\n                        InvalidateCache();\n                        break;\n                    default:\n                        _trace.WriteLine($\"Failed to unset config entry '{name}' (exit={git.ExitCode}, level={level})\");\n                        throw GitProcess.CreateGitException(git, $\"Failed to unset Git configuration entry '{name}'\");\n                }\n            }\n        }\n\n        public IEnumerable<string> GetAll(GitConfigurationLevel level, GitConfigurationType type, string name)\n        {\n            if (_useCache)\n            {\n                EnsureCacheLoaded(type);\n\n                ConfigCache cache = _cache[type];\n                if (cache.IsLoaded)\n                {\n                    var cachedValues = cache.GetAll(name, level);\n                    foreach (var val in cachedValues)\n                    {\n                        yield return val;\n                    }","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitConfiguration.cs#L625-L661","documentation":"Thrown by GitConfiguration.Unset when `git config --unset <name>` exits with an unexpected code. Exit 0 and exit 5 (key/value does not exist) are treated as success, so this fires only on real failures: invalid key name or an unwritable config file (unset rewrites the file).","triggerScenarios":"Calling Unset(level, name) with a malformed key or when git cannot rewrite the config file — read-only file, permission denied, or config parse error. Note exit 5 (nothing to unset) is NOT an error.","commonSituations":"Unsetting a key whose name has no section ('useremail' vs 'user.email'); .git/config owned by root or another user; config locked by another process; malformed config preventing rewrite.","solutions":["Confirm the key exists with `git config --get <name>`; remember exit 5 (missing) is tolerated, so this error implies something else","Check write permissions on the config file — unset rewrites the whole file","Fix any config parse errors (`git config --list`) that block rewriting","Run `git config --unset <name>` manually to see the precise git error"],"exampleFix":"// before\nconfig.Unset(level, \"core.bare\"); // throws if .git/config read-only\n// after\ntry { config.Unset(level, \"core.bare\"); }\ncatch (GitException ex) { Log($\"Could not unset core.bare: {ex.Message}\"); }","handlingStrategy":"try-catch","validationCode":"var probe = Process.Run(\"git\", $\"config --get {name}\", workingDir);\n// exit 1 = key absent (Unset tolerates); proceed only if probe.ExitCode == 0 or 1","typeGuard":null,"tryCatchPattern":"try { cfg.Unset(level, name); }\ncatch (GitException ex) { log.Error($\"Unset '{name}' failed: {ex.Message}\"); }","preventionTips":["Remember exit 5 (missing key) is tolerated — this error implies a write/parse failure, so check file permissions","Ensure the process user owns or can write the config file","Close editors/IDEs holding config file locks","Fix malformed config before unsetting (unset rewrites the whole file)"],"tags":["git","config","write"],"backgroundTag":"git-command-failed","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}