The following command:

$git config --global --list

gives me:

user.name=test user

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

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.

8 Answers 8


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

  • 2
    Thanks, that works, but is there a way to edit it using commands too?
    – gotqn
    Oct 26, 2012 at 6:10
  • @gotqn you can use cat or gedit to edit that.
    – MrYo
    Aug 15, 2013 at 7:29
  • 2
    @gotqn gedit ~/.gitconfig OR nano ~/.gitconfig Feb 22, 2014 at 21:41
  • 4
    @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, 2014 at 17:04

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>
  • 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. Sep 4, 2014 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, 2017 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 3, 2022 at 5:39
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"
  • 11
    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, 2013 at 8:22
git config --global -e

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


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

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.


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

        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
        email = <username>@gmail.com
[remote "origin"]
        url = https://github.com/<username>/<repo_name>.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        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


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

git config --unset-all core.editor


git config --list

and see no changes.

The answer was to run:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .