设置当前项目的 Git 用户邮箱

使用 git 命令设置当前项目的 config 信息

要设置当前 Git 项目的用户邮箱(user email),你可以使用以下命令:

设置当前项目的用户邮箱(局部配置):

git config user.email "你的邮箱@example.com"

这个配置会保存在当前项目的 .git/config 文件中,仅对当前项目生效。


示例:

git config user.email "zhangsan@example.com"

你可以通过以下命令验证是否设置成功:

git config user.email

如果你想设置全局的邮箱(对所有项目生效):

git config --global user.email "你的邮箱@example.com"

小提示:

通常建议为 Git 配置全局的用户名和邮箱,命令如下:

git config --global user.name "YourName"
git config --global user.email "your@email.com"

这样你每次提交代码时,Git 都会记录你的名字和邮箱。

如有更多 Git 配置相关问题,也欢迎继续提问!