How can I remove an entry in global configuration with git config?

Viewed 566305

I ran a global configuration command in git to exclude certain files using a .gitignore_global file:

git config --global core.excludesfile ~/.gitignore_global

Is there a way to undo the creation of this setting globally?

10 Answers

You can use the --unset flag of git config to do this like so:

git config --global --unset user.name
git config --global --unset user.email

If you have more variables for one config you can use:

git config --global --unset-all user.name

You can check all the config settings using

git config --global --list

You can remove the setting for example username

git config --global --unset user.name

You can edit the configuration or remove the config setting manually by hand using:

git config --global --edit 

Try these commands to remove all users' usernames and emails.

git config --global --unset-all user.name
git config --global --unset-all user.email

In order to complement the larsk anwser, is possible remove an entry line while editing with vim using the dd command:

git config --global --edit

then:

  • Press the Esc key to go to normal mode.
  • Place the cursor on the line you want to delete.
  • Type dd and hit Enter to remove the line.

when you finish, type ESQ and :wq

If someone just wanna delete the user object entirely, then he should use:

git config --global --remove-section user

This is useful when a user accidentally adds more properties that are not required just like user.password etc.

You can edit the ~/.gitconfig file in your home folder. This is where all --global settings are saved.

git config information will stored in ~/.gitconfig in unix platform.

In Windows it will be stored in C:/users/<NAME>/.gitconfig.

You can edit it manually by opening this files and deleting the fields which you are interested.

Related