To check if you have configured the git username and email on the local environment, use the following command:
1. Check git username and email
1.1 Method 1: use git command
$ git config --list
If you have configured username and email before, there you should find user.name
and user.email
.
If you haven’t configure a username and email, the outcome would looks like this:
1.2 Method 2: check the ‘~/.gitconfig’ file
$ cat ~/.gitconfig
2. check only git username or email
$ git config user.name
$ git config user.email
3. Configure or change user name and email
If you have not configured username and email before, you can use the following command:
$ git config --global user.name "yourName"
$ git config --global user.email "your@email.com"
Another way to change it is to edit the Git config file in your HOME directory and change it there:
vi ~/.gitconfig