Git stores configuration settings at three levels:
- System — applies to all users on the machine
- Global — applies to your user account
- Local — applies to the current repository only
Sometimes you want to remove or unset a configuration value. Here’s how.
🔧 Command to Unset a Git Config Value
Use:
git config --unset <key>
By default, this affects the local config (in the current repo).
🔄 Examples
Unset local config (in current repo)
git config --unset user.name
Unset global config (for your user)
Add --global
flag:
git config --global --unset user.email
Unset system config (rarely used)
Add --system
flag (may require admin rights):
git config --system --unset core.editor
🧠 Notes
- If the key is set multiple times, you can use
--unset-all
to remove all instances:
git config --unset-all <key>
- To view current config:
git config --list
Or for a specific scope:
git config --global --list
Summary Table
Command | Purpose |
---|---|
git config --unset <key> | Remove key from local config |
git config --global --unset <key> | Remove key from global config |
git config --system --unset <key> | Remove key from system config |
git config --unset-all <key> | Remove all entries for a key |