87

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.

92

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

  • Thanks, that works, but is there a way to edit it using commands too? – gotqn Oct 26 '12 at 6:10
  • @gotqn you can use cat or gedit to edit that. – Sanjaya Pandey Aug 15 '13 at 7:29
  • 1
    @gotqn gedit ~/.gitconfig OR nano ~/.gitconfig – Giri Feb 22 '14 at 21:41
  • 2
    @Giri or you could use vim... or ex or ed or butterflies that focus the cosmic energy in the upper atmosphere that then flip the correct bits in your drive platter. – dylnmc Oct 31 '14 at 17:04
86

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>
  • 4
    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 4 '14 at 9: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 8 '17 at 15:42
8
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"
  • 10
    This answer was essentially already provided in the question by user25327. I think the addition of the --replace-all option should be a comment. – gertvdijk Jun 26 '13 at 8:22
5
git config --global -e

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

2

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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.