Git user FAQ: How do I show or change my Git username or email address?
How to show your Git username
There are at least three ways to show your Git username:
- The
git config
command - The
git config --list
command - Looking in your Git configuration file
The following sections describe each solution.
1) The `git config` command
Use the git config
command like this to show your Git username:
git config user.name
In my case this returns:
Alvin Alexander
2) The `git config --list` command
Another way to show your Git username is with this git config
command:
git config --list
which returns this output:
user.name=Alvin Alexander user.email=[omitted] merge.tool=vimdiff
3) Look in your Git configuration file
Finally, you can also see your Git username in the Git configuration file in your HOME
directory on Unix systems, i.e., this file:
~/.gitconfig
My file on my current test system looks like this:
[user] name = Alvin J. Alexander email = [omitted] [merge] tool = vimdiff
It’s important to note that this is your “global” Git username. You can also have a different username on a per-project basis (but I haven’t used that yet).
How to change your Git username
You can change your Git username like this:
git config --global user.name "Alvin J. Alexander"
Another way to change it is to edit the Git config file in your HOME
directory and change it there:
vi ~/.gitconfig
I just did that on my MacOS system, and it seems to work fine.
Note: Per-project username
Again, it’s important to note that this is your “global” username. You can also have a different username on a per-project basis ... I just looked it up, and you should be able to change your Git username on a per-project basis like this, without the --global
option:
git config user.name "Alvin J. Alexander"
How to view and change your Git email address
While I’m in the Git username neighborhood, I’ll also add that you can view your Git email address with this command:
git config user.email
And you can change your Git email address like this:
git config --global user.email [your email address here]
Finally, you can also see your password by viewing the Git config file in your HOME
directory:
more ~/.gitconfig