109

The following command:

$git config --global --list

gives me:

user.name=test user
user.name=gotqn

I want to remove the first name. I referred to this article and have done the following commands but without any result:

git config --global --remove-section user.name='test user'
git config --global --remove-section user.name="test user"
git config --global --remove-section user.name=test user
git config --global --remove-section user.name
git config --global --remove-section test user

I am using Ubuntu 12.04 and

git version

gives me

git version 1.7.9.5

Please, help on this, because I want to try to save my project using git, but do not want to exec the command with 'test user' name.

gotqn
  • 2,047

8 Answers8

118

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

BuZZ-dEE
  • 14,223
Marco Ceppi
  • 48,101
104

Super late answer, but hopefully still helpful:

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

Then you're free to:

git config --global --add user.name <whatever>
thefourtheye
  • 4,924
njmason
  • 1,141
  • 7
    I think this is the best answer. Since the configuration is already made via command line, I think the reverse operation should be done via command line. Otherwise do all configuration in the config file. – Johan Karlsson Sep 04 '14 at 09:56
  • This also works in the scenario you set a user.name in a local repo instead of global. Just remove the --global flag from both commands. – styfle Mar 08 '17 at 15:42
  • You can also remove the email by executing git config --global --unset-all user.email if you need to. – x__x Aug 03 '22 at 05:39
10
git config --global --unset-all user.name

Or you can just change the user name like this:

git config --global --replace-all user.name "New User Name"
Crusader
  • 210
  • 2
  • 5
6
git config --global -e

This command will open GNU nano editor with what you are expecting.

gobi
  • 161
3

Last but not least usefull, although it's a marginal case is to use

git config --global --remove-section user

In my case it cleared the data perfectly and with little to no effort

1

You can edit your .git/config file present in the local repository repo manually as below:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[user]
        email = <username>@gmail.com
[remote "origin"]
        url = https://github.com/<username>/<repo_name>.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[credential]
        username = <user_name>
[credential "user"]
        email = <username>@gmail.com
[branch "master"]
        remote = origin
        merge = refs/heads/master
"config" 19L, 427C

Now try in terminal:

git push -origin master

1
git config user.name 'your user name'
git config user.email 'your email name'

you can config for your every company project。And global's user name set your private github name and email.I thought this should be the best way for handle this condition.

muru
  • 197,895
  • 55
  • 485
  • 740
Feng Li
  • 11
0

I was having trouble trying to clear out double entries for core.editor... I'd run

git config --unset-all core.editor

then

git config --list

and see no changes.

The answer was to run:

git config --global --unset-all core.editor