feat: split git user identity by repo directory

Leave global name/email empty with useConfigOnly so unmatched repos cannot commit. Personal identity applies under ~/.dotfile, ~/code, and ~/.pouch; work identity stays in local ~/.gitconfig.work for ~/workrepo.
This commit is contained in:
2026-09-14 14:55:44 +08:00
parent 097fce7827
commit 0b04a4de50
4 changed files with 35 additions and 3 deletions
+12 -3
View File
@@ -1,6 +1,7 @@
# 不设全局 user.name / user.email,避免未匹配目录误用身份。
# useConfigOnly(Git 2.8+):未配置时拒绝 commit,而不是猜系统用户名。
[user]
name = laily
email = i@laily.net
useConfigOnly = true
[core]
autocrlf = input
quotepath = false
@@ -42,8 +43,16 @@
[mergetool "nvimdiff"]
cmd = nvim -d \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
# 按仓库目录套身份。个人身份在 git/.gitconfig.personal;公司邮箱只放本机 ~/.gitconfig.work。
# include 目标文件必须存在,否则该目录下 git 命令会直接 fatal。
[includeIf "gitdir:~/.dotfile/"]
path = ~/.dotfile/git/.gitconfig.personal
[includeIf "gitdir:~/code/"]
path = ~/.dotfile/git/.gitconfig.personal
[includeIf "gitdir:~/.pouch/"]
path = ~/.dotfile/git/.gitconfig.personal
[includeIf "gitdir:~/workrepo/"]
path = ~/.workgitconfig
path = ~/.gitconfig.work
[rebase]
autoSquash = true
autoStash = true
+4
View File
@@ -0,0 +1,4 @@
# 个人身份:~/.dotfile、~/code、~/.pouch(由 includeIf gitdir 加载)
[user]
name = laily
email = i@laily.net