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
+4
View File
@@ -61,6 +61,10 @@ ff reload # 重载 fish 配置
## Git 配置
- 公共配置在 `git/.gitconfig`
- **身份**:不设全局 `user.name` / `user.email`,`user.useConfigOnly = true`。未匹配目录时拒绝 commit,避免错用身份
- `~/.dotfile/`、`~/code/`、`~/.pouch/` → `git/.gitconfig.personal`(个人,进仓库,已写 name/email)
- `~/workrepo/` → `~/.gitconfig.work`(公司,仅本机;`git-init` 会生成空模板)
- include 目标文件必须存在,否则该目录下 git 命令会 fatal
- **凭据**(所有 Git 版本):`git/git-credential.sh` 写在主配置里,使用 `!$HOME/.dotfile/...`(Git 不展开 `~`)
- macOS:`osxkeychain` → 回退 `store`(`~/.git-credentials`)
- Linux:`libsecret` → 回退 `store`