How to fix warning: cannot overwrite multiple values with a single value in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 203 views

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.

Quick fix

Fixes warning: cannot overwrite multiple values with a single value

# 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.name
  1. Identify which config file has duplicates
  2. Use --replace-all to fix the value
  3. Alternatively, unset all values first
  4. Manually edit the config file
git โ€” error
# 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.name
warning: cannot overwrite multiple values with a single value

What this error means

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.

Typical symptoms

  • Git config command fails with 'warning: <key> has multiple values' followed by 'error: cannot overwrite multiple values'
  • Error message suggests using 'a regexp, --add or --replace-all'
  • Running git config --list shows the same key appearing multiple times with different values
  • Git operations work but config changes are rejected
  • The error occurs with user.name, user.email, credential.helper, or other config keys

Common causes

  1. Running git config --add multiple times for the same key without realizing it
  2. Credential helpers (like osxkeychain or store) being added multiple times to config
  3. Scripts or automation tools appending config values without checking for existing entries
  4. Manually editing .gitconfig and accidentally duplicating key entries
  5. Merge conflicts in config files that weren't properly resolved
  6. Using git config with a value_regex that matched nothing, causing a new entry to be added

How to fix "warning: cannot overwrite multiple values with a single value"

1Identify which config file has duplicates

First, find where the duplicate values are located using --get-all at each level:

bash
# 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.name

The 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:

bash
git config --show-origin --show-scope --get-all user.name

This will show the exact file path and scope (system/global/local) for each value.

2Use --replace-all to fix the value

The quickest fix is to use the --replace-all flag, which replaces all occurrences of the key with your new value:

bash
# 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.

3Alternatively, unset all values first

If you prefer a two-step approach, first remove all values, then set the correct one:

bash
# 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.

4Manually edit the config file

For more control, edit the config file directly:

bash
# Edit global config
git config --global --edit

# Or edit local config
git config --local --edit

Look for duplicate entries like:

ini
[user]
    name = John Doe
    name = Jane Doe    # <- duplicate, remove this line
    email = john@example.com

Remove the duplicate lines, keeping only the value you want. Save and exit the editor.

5View all config to find other duplicates

Check your entire Git configuration for any other duplicate keys:

bash
# List all config with origins
git config --list --show-origin

# Or just list all values
git config --list

Look 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

6Fix credential.helper duplicates (common on macOS)

On macOS, credential.helper often ends up with multiple values:

bash
# 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 osxkeychain

On other systems, you might want:

bash
# 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-core
7Verify the fix

After making changes, verify that the key now has only one value:

bash
# 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.name

If you no longer see the "multiple values" warning, the issue is resolved.

Advanced notes

### 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:

bash
# Replace only the value "store" with "osxkeychain"
git config --global credential.helper osxkeychain store

The last argument is a regex pattern - only values matching it will be replaced.

Frequently asked questions

What does "warning: cannot overwrite multiple values with a single value" mean?
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/config).
How do I fix "warning: cannot overwrite multiple values with a single value"?
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.
What causes "warning: cannot overwrite multiple values with a single value"?
Running git config --add multiple times for the same key without realizing it Credential helpers (like osxkeychain or store) being added multiple times to config Scripts or automation tools appending config values without checking for existing entries
Is the "warning: cannot overwrite multiple values with a single value" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading