Git: changing global user name and user email

How to set the global user name and user email for git?

We may be asked to set our global user name and user email if it is the first time that we use git on a machine:

Your name and email address were configured automatically based on
your username and hostname. Please check that they are accurate. You
can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit --amend --author='Your Name <you@example.com>'

However, no message tells us how to update these information (of course, git does not know that we want to change). To change the configurations, the same scripts can be used:

$ git config --global user.name "Your Name"
$ git config --global user.email you@example.com

# fix wrong identity
$ git commit --amend --author='Your Name <you@example.com>'
Leave a Reply

Your email address will not be published. Required fields are marked *