{"record":{"id":"6c0ed4e9dc0952be","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-replace-all-git-configuration-multi-valu","errorCode":null,"errorMessage":"Failed to replace all Git configuration multi-valued entries '{name}'","messagePattern":"Failed to replace all Git configuration multi-valued entries '(.+?)'","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GitConfiguration.cs","lineNumber":768,"sourceCode":"            var gitArgs = $\"config {levelArg} --replace-all {QuoteCmdArg(name)} {QuoteCmdArg(value)}\";\n            if (valueRegex != null)\n            {\n                gitArgs += $\" {QuoteCmdArg(valueRegex)}\";\n            }\n\n            using (ChildProcess git = _git.CreateProcess(gitArgs))\n            {\n                git.Start(Trace2ProcessClass.Git);\n                git.WaitForExit();\n\n                switch (git.ExitCode)\n                {\n                    case 0: // OK\n                        InvalidateCache();\n                        break;\n                    default:\n                        _trace.WriteLine($\"Failed to replace all multivar '{name}' and value regex '{valueRegex}' with new value '{value}' (exit={git.ExitCode}, level={level})\");\n                        throw GitProcess.CreateGitException(git, $\"Failed to replace all Git configuration multi-valued entries '{name}'\");\n                }\n            }\n        }\n\n        public void UnsetAll(GitConfigurationLevel level, string name, string valueRegex)\n        {\n            EnsureSpecificLevel(level);\n\n            string levelArg = GetLevelFilterArg(level);\n            var gitArgs = $\"config {levelArg} --unset-all {QuoteCmdArg(name)}\";\n            if (valueRegex != null)\n            {\n                gitArgs += $\" {QuoteCmdArg(valueRegex)}\";\n            }\n\n            using (ChildProcess git = _git.CreateProcess(gitArgs))\n            {\n                git.Start(Trace2ProcessClass.Git);","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitConfiguration.cs#L750-L786","documentation":"Thrown when `git config --replace-all <name>` exits non-zero. ReplaceAll rewrites every values matching an optional value regex; failure typically means the key name is invalid, the value regex is malformed, or the config file cannot be written back.","triggerScenarios":"Calling ReplaceAll(level, name, valueRegex, value) with an invalid key, a bad value regex, or when git cannot rewrite the target config (read-only, locked, malformed existing config).","commonSituations":"Replacing values for a misspelled key; regex with special characters that break git's parsing; config file locked by another git process or IDE.","solutions":["Run `git config --replace-all <name> <valueRegex> <value>` manually to see git's error","Validate the key name format and escape regex metacharacters in valueRegex","Ensure the config file is writable and not locked by another process","Fix any existing config parse errors before rewriting"],"exampleFix":"// before\nconfig.ReplaceAll(level, \"remote.origin.url\", \"*\", newUrl); // '*' breaks git parsing\n// after\nconfig.ReplaceAll(level, \"remote.origin.url\", \".*\", newUrl); // valid regex","handlingStrategy":"validation","validationCode":"static bool IsValidConfigKey(string name) {\n    var parts = name.Split('.');\n    return parts.Length >= 2 && parts.All(p => p.Length > 0);\n}\n// use \".*\" not \"*\" for match-all valueRegex","typeGuard":null,"tryCatchPattern":"try { cfg.ReplaceAll(level, name, valueRegex, value); }\ncatch (GitException ex) { log.Error($\"ReplaceAll '{name}' failed: {ex.Message}\"); }","preventionTips":["Validate key format and use '.*' for match-all regexes","Backup .git/config before bulk replace operations","Ensure no other git process holds the config file lock","Prefer Set/Add for single-value writes; reserve ReplaceAll for genuine multivar use"],"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-16T14:17:13.074Z"}