本文转载至:https://help.github.com/articles/setting-your-email-in-git/
简述:
使用下面的命令设置全局的邮箱。
git config --global user.email "your_email@example.com"
使用下面的命令设置本地的邮箱。(仅是当前的repo)
git config user.email "your_email@example.com"
GitHub uses the email address you set in your local Git configuration to associate commits with your GitHub account.
Setting your local Git email address using the git config
command
The git config
command can be used to change your Git configuration settings,including your email address. It takes two arguments:
- The setting you want to change--in this case,
user.email
. - Your new email address--for example,
your_email@example.com
. Be sure to use your own real, unique email address.
Your email address will be visible on commits to GitHub. If you'd like to keep your email address private, set your Git config email to username@users.noreply.github.com
instead, replacing username
with your GitHub username. For more information, see "Keeping your email address private".
Setting your email address for every repository on your computer
-
Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).
-
Set your email address with the following command:
git config --global user.email "your_email@example.com"
-
Confirm that you have set your email address correctly with the following command.
git config --global user.email your_email@example.com
Setting your email address for a single repository
You may need to set a different email address for a single repository, such as a work email address for a work-related project.
-
Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).
-
Change the current working directory to the local repository in which you want to set your Git config email.
-
Set your email address with the following command:
git config user.email "your_email@example.com"
-
Confirm that you have set your email address correctly with the following command.
git config user.email your_email@example.com