Unsetting git configuration settings

Greg Foster
Greg Foster
Graphite software engineer

Git configurations are stored in three main levels:

  1. System level: Applies settings universally to every user on the system and all their repositories.
  2. Global level: Applies settings to a user’s profile and all the repositories they interact with.
  3. Local level: Applies settings to a specific repository.

The configurations can include user credentials, preferred text editors, diff tools, and other settings that control Git's behavior.

Before unsetting a configuration, you might want to view the current settings. You can see all configurations or a specific configuration using the following commands:

git config --list --show-origin # Shows all configurations with their origins
git config --global --list # Shows global configurations
git config --local --list # Shows configurations for the current repository

To remove a specific configuration entry, use the git config --unset command followed by the key of the configuration. For example, to unset the user name in the global config, run:

git config --global --unset user.name

This command removes the user.name setting from the global configuration.

To remove a global configuration variable, you would use the same approach but specify the global option:

git config --global --unset <key>

Replace <key> with the name of the configuration key you want to remove. For example, to delete a global email configuration:

git config --global --unset user.email

Similarly, if you want to delete a configuration that is set at the local repository level:

git config --local --unset <key>

For instance, to remove a local repository's specific configuration for a diff tool:

git config --local --unset diff.tool

If you need to reset your Git configurations to their default settings, you should remove the configuration file. Git will recreate these files with default settings the next time it needs them.

To reset all global configurations, you can delete the global configuration file:

rm ~/.gitconfig

This command deletes the global Git configuration file, effectively resetting all global configurations to their defaults.

For local repository configurations, you can remove the config file in the .git directory:

rm .git/config

This action resets all configurations specific to the current repository.

For further reading on the Git configuration, see the official git documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2