493

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?

Bazer Con
  • 105
  • 4
hatmatrix
  • 39,823
  • 42
  • 131
  • 224

10 Answers10

875

I'm not sure what you mean by "undo" the change. You can remove the core.excludesfile setting like this:

git config --global --unset core.excludesfile

And of course you can simply edit the config file:

git config --global --edit

...and then remove the setting by hand.

larsks
  • 228,688
  • 37
  • 348
  • 338
  • 4
    Just if you have the same key repeated (because you did an --add instead of --edit), this command will not work but you can do `git config --replace-all core.excludesfile "your_value"` – Juan Saravia Jan 30 '15 at 12:04
  • 2
    I wanted to change this back to "input" but found the existing setting under `system` scope so I used `git config --system --edit` to change my entry. – colin_froggatt May 06 '15 at 13:05
  • "You can tell Git to convert CRLF to LF on commit but not the other way around by setting core.autocrlf to input:" From: http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace – colin_froggatt May 06 '15 at 13:11
  • 4
    For Windows, you can edit the file at C:\Users\%USERNAME%\.gitconfig – Shital Shah Oct 27 '16 at 04:50
  • In my case, this does not work for some filter settings; I was able to find the file by `git config -l --show-origin` and I went to the file to edit its content. – WesternGun Nov 28 '18 at 15:33
  • @larsks I am afraid the second one will work only if `core.editor` is correct :-) – Alessandro Jacopson Feb 13 '19 at 15:47
84

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
mcrute
  • 1,554
  • 15
  • 26
Yousry Elwrdany
  • 849
  • 6
  • 4
29

Open config file to edit :

git config --global --edit

Press Insert and remove the setting

and finally type :wq and Enter to save.

28

Try this from the command line to change the git config details.

git config --global --replace-all user.name "Your New Name"

git config --global --replace-all user.email "Your new email"
Prabhakar Undurthi
  • 6,272
  • 2
  • 39
  • 50
21

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 
AConsumer
  • 1,921
  • 2
  • 18
  • 30
14

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

git config --global --unset-all user.name
git config --global --unset-all user.email
Ankit Kumar Rajpoot
  • 5,032
  • 1
  • 38
  • 28
8

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

Victor
  • 5,142
  • 4
  • 12
  • 29
Samuel Diogo
  • 517
  • 9
  • 11
7

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.

Aun Abbas
  • 430
  • 6
  • 13
5

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.

Book Of Zeus
  • 48,853
  • 18
  • 173
  • 169
4

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

Angelo Mendes
  • 747
  • 10
  • 21