【发布时间】:2018-04-05 11:22:22
【问题描述】:
显然可以强制 Git 用户使用以下gitconfig 设置为每个新存储库添加一个电子邮件地址:
git config --global user.email "(none)"
git config --global user.useConfigOnly true
我已经做到了。我的gitconfig -l 输出(截断):
core.symlinks=true
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
diff.astextplain.textconv=astextplain
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
credential.helper=manager
core.autocrlf=true
core.eol=native
user.name=David Wright
user.email=(none)
user.useconfigonly=true
但它似乎不起作用。我可以在不设置电子邮件地址的情况下提交。提交中列出的电子邮件地址(哦,奇怪)是“(无)”。
我正在使用git version 2.13.0.windows.1。
我想这样做是因为我在同一台计算机上使用两个不同的帐户。我能够在我的ssh-config 文件中应用不同的 ssh 密钥来实现类似的设置:
# github account
Host github.com
Port 22
HostName github.com
User git
IdentityFile <file>
但显然 git 本身没有这种可能性。
无论如何,我希望能够强制我必须为每个存储库设置一个用户电子邮件地址,并且我希望这成为我的 global gitconfig 的一部分。我知道使用预提交挂钩可以做到这一点,但据我所知,这个挂钩需要在克隆后复制到每个仓库,这不是我想要的。
【问题讨论】:
标签: git git-config