【发布时间】:2019-03-12 23:15:04
【问题描述】:
我将 Git 与两个不同的电子邮件/个人资料一起使用,结果是:
git config user.email >> myRepoEmail@address.com
git config --global user.email >> myGenericEmail@address.com
如果我使用 VS Code 并打开终端,我的提交使用 repo 电子邮件地址;这是有道理的,因为我有效地使用了 Git(而不是 VSCode)。但是,如果我使用源代码管理 Git 侧边栏并键入提交消息、Ctrl+Enter 提交等,那么它使用全局电子邮件 (myGenericEmail@address.com) 提交,即使我在一个具有不同设置。
有没有办法告诉 VS Code 使用 repo 的设置进行提交,而不是调用 --global 进行提交?
[编辑来自 cmets 的信息]
我想我应该提到我的 gitconfig 中有命令
[includeIf "gitdir:C:/Users/myname/privateRepoFolder"]
path = ~/gitconfig-private
在那个备用 gitconfig-private 中,我有
[user]
email = myRepoEmail@address.com
【问题讨论】:
-
我似乎无法重现这一点。
git config --local --get user.email的输出是什么? -
在我的环境中,
--local输出 repo 的电子邮件地址,当我使用源代码控制面板提交时,VS Code 会尊重该地址。当我删除--localuser.email时,VS Code 将恢复为--globaluser.email。 -
大多数时候,我只是使用我的全局设置,只有对于特殊项目/repos,我才需要设置特殊的
--localuser.*设置。我要补充一点,我在 Ubuntu/MacOS 上,还没有在 Windows 上检查你的问题,你似乎在。 -
@Gino 成功了。随意添加作为答案,我会将其标记为已解决。
标签: git visual-studio-code vscode-settings