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
1) The `git config` command
Here’s the git config
command:
git config user.name
which in my case 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 test system, and it seems to work fine.
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 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