This Git config error occurs when you try to set a configuration key that already has multiple values. Use --replace-all to overwrite all values, or manually remove duplicates from your config file.
The "cannot overwrite multiple values with a single value" warning in Git indicates that your Git configuration file contains duplicate entries for the same key. When you try to update that key with a standard `git config` command, Git refuses because it doesn't know which of the multiple values you want to replace. Git configuration can exist at three levels: system (/etc/gitconfig), global (~/.gitconfig), and local (.git/config). Each level can potentially contain entries, and within a single file, the same key might accidentally appear multiple times. This commonly happens when: - Running `git config --add` multiple times without realizing it - Scripts or tools modifying config files without checking for existing values - Manually editing config files and accidentally duplicating sections - Using credential helpers that add values each time they're invoked The error is actually Git being cautious - it wants explicit instructions on how to handle the multiple values rather than silently choosing one to keep.
First, find where the duplicate values are located using --get-all at each level:
# Check local repository config
git config --local --get-all user.name
# Check global user config
git config --global --get-all user.name
# Check system-wide config
git config --system --get-all user.nameThe config file that returns more than one value is the one that needs to be fixed. You can also see the origin of each value:
git config --show-origin --show-scope --get-all user.nameThis will show the exact file path and scope (system/global/local) for each value.
The quickest fix is to use the --replace-all flag, which replaces all occurrences of the key with your new value:
# For global config
git config --global --replace-all user.name "Your Name"
# For local config
git config --local --replace-all user.name "Your Name"
# For system config (requires admin/root)
sudo git config --system --replace-all user.name "Your Name"This removes all existing values for that key and sets a single new value.
If you prefer a two-step approach, first remove all values, then set the correct one:
# Remove all values for the key
git config --global --unset-all user.name
# Set the correct value
git config --global user.name "Your Name"This approach is useful when you want to verify the key is completely cleared before setting a new value.
For more control, edit the config file directly:
# Edit global config
git config --global --edit
# Or edit local config
git config --local --editLook for duplicate entries like:
[user]
name = John Doe
name = Jane Doe # <- duplicate, remove this line
email = [email protected]Remove the duplicate lines, keeping only the value you want. Save and exit the editor.
Check your entire Git configuration for any other duplicate keys:
# List all config with origins
git config --list --show-origin
# Or just list all values
git config --listLook for any key that appears multiple times. Common culprits include:
- credential.helper (especially on macOS)
- user.name and user.email
- merge.tool and diff.tool
- core.autocrlf
On macOS, credential.helper often ends up with multiple values:
# Check for duplicates
git config --global --get-all credential.helper
# If you see multiple values like:
# osxkeychain
# store
# osxkeychain
# Replace all with your preferred helper
git config --global --replace-all credential.helper osxkeychainOn other systems, you might want:
# Linux - use libsecret or cache
git config --global --replace-all credential.helper cache
# Windows - use manager-core
git config --global --replace-all credential.helper manager-coreAfter making changes, verify that the key now has only one value:
# Should return only one value
git config --global --get-all user.name
# Test setting a value (should work without errors now)
git config --global user.name "Your Name"
# Confirm the value is set correctly
git config --global user.nameIf you no longer see the "multiple values" warning, the issue is resolved.
### Why Git Allows Multiple Values
Some Git config keys are designed to have multiple values. For example, remote.origin.fetch can have multiple refspecs, and include.path can include multiple config files. When you use git config --add, you're explicitly adding another value to a potentially multi-valued key.
The error occurs when you try to use the standard git config key value syntax (without --add) on a key that already has multiple values. Git's default behavior is to replace a single value, not to handle multiple values.
### Config File Locations
Understanding where Git stores configuration helps debug issues:
| Scope | Flag | Location |
|-------|------|----------|
| System | --system | /etc/gitconfig or $(prefix)/etc/gitconfig |
| Global | --global | ~/.gitconfig or ~/.config/git/config |
| Local | --local | .git/config in the repository |
| Worktree | --worktree | .git/config.worktree |
Values from more specific scopes override less specific ones (local > global > system).
### Preventing Future Duplicates
To avoid this issue in the future:
1. Use git config key value (without --add) for keys that should have single values
2. Check if a value exists before adding: git config --get key || git config key value
3. Use --replace-all in scripts that might run multiple times
4. Avoid manually editing config files unless necessary
### Pattern-Based Replacement
For advanced use cases, you can replace only values matching a pattern:
# Replace only the value "store" with "osxkeychain"
git config --global credential.helper osxkeychain storeThe last argument is a regex pattern - only values matching it will be replaced.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server