git配置个人和公司的提交信息
一般公司的git的commit信息都是你的真实姓名+你的公司邮箱(公司规定)
但是你在做个人项目或者demo时,不想透露自己的真名或者其他信息(隐私保护)
于是我们可以通过配置多份gitconfig来区分 个人项目和公司项目
实现:
将个人项目和公司项目分开在两个目录下
对这个两个目录下的git提交做配置
扩展:
你可以配置多个目录下的git commit提交信息
只要把配置目录搞对就是了
it's up to you
~/.gitconfig
shell
...
[includeIf "gitdir/i:~/Documents/Personal/"]
path = ~/.gitconfig_personal
[includeIf "gitdir/i:~/Documents/Work/"]
path = ~/.gitconfig_companyname
~/.gitconfig_personal
shell
[user]
name = Your Personal Name
email = your_personal@email.com
~/.gitconfig_companyname
shell
[user]
name = Your Personal Name
email = your_personal@email.com
查看
shell
git config -l # 在项目目标下执行此命令 看是否正确配置
git config --show-origin --get user.name # 看个人名称
git config --show-origin --get user.email # 看邮箱