4
三种方式 轻松设置 Git 提交者 email等信息 - 技术小黑屋
source link: https://droidyue.com/blog/2021/06/28/multiple-ways-to-set-git-author-email/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
三种方式 轻松设置 Git 提交者 Email等信息
Jun 28th, 2021
- 针对项目 A 使用 [email protected] 邮箱
- 针对除了项目A之外的项目 使用 [email protected] 邮箱
git 配置的三种作用范围
- 项目级,英文为
project
. - 全局(当前用户),英文为
global
. - 系统级(针对所有用户),英文为
system
.
项目级配置
为当前项目设置[email protected]
作为代码提交者的邮箱。
git config user.email "[email protected]"
检索一下设置,进行验证是否成功
git config --get user.email
[email protected]
- 该设置只针对于当前项目,其他项目不生效。
- 该项目对应的远程地址再次clone 下来的项目也不生效。
- 该修改不会随着
git push
推送到远程服务器中。 - 配置设置持久化在当前项目的
.git/config
文件中。
我们为当前用户设置默认的代码提交者的邮箱(即例子中除A项目外的)
git config --global user.email "[email protected]"
再次检索一下配置是否生效
git config --global --get user.email
[email protected]
- 该配置方式只对当前用户生效,其他用户不生效。
- 配置设置持久化在
~/.gitconfig
文件中。
系统级设置
这是一种为所有的用户和项目设置默认git配置的方式
sudo git config --system user.email "[email protected]"
再次验证一下配置是否生效
git config --system --get user.email
[email protected]
- 这种设置需要使用root权限
- 配置设置持久化在
/etc/gitconfig
中。 - 一般情况下这种配置使用频率不高。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK