603

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
  • 42,883
  • 45
  • 137
  • 231

11 Answers11

1054

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
  • 277,717
  • 41
  • 399
  • 399
  • 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
  • 1
    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
115

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,592
  • 1
  • 16
  • 27
Yousry Elwrdany
  • 1,159
  • 1
  • 7
  • 4
42

Open config file to edit :

git config --global --edit

Press Insert and remove the setting

and finally type :wq and Enter to save.

31

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
  • 6,458
  • 2
  • 40
  • 51
27

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
  • 2,461
  • 2
  • 25
  • 33
22

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

Jackdaw
  • 7,626
  • 5
  • 15
  • 33
Samuel Diogo
  • 689
  • 10
  • 13
19

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,188
  • 2
  • 38
  • 32
10

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
  • 540
  • 7
  • 18
6

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

Angelo Mendes
  • 905
  • 13
  • 24
6

This would unset global credential helper.

git config --global --unset credential.helper
Clubman
  • 81
  • 1
  • 3
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
  • 49,509
  • 18
  • 174
  • 171