我有全局 git 配置 (~/.gitconfig),我的电子邮件是 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="eb9884868ebe988e99ab9884868e8e868a8287c5888486" rel="noreferrer noopener nofollow">[email protected]</a>
。
当我在本地存储库中时(我之前使用 https 进行了身份验证)并且输入 git config user.email
我的用户名仍然是 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b5844464e7e584e596b5844464e4e464a424705484446" rel="noreferrer noopener nofollow">[email protected]</a>
。
但是,对于这个本地存储库,我使用的电子邮件地址与我拥有的电子邮件地址和配置中显示的电子邮件地址不同。
问题是,git 如何知道要使用哪个电子邮件/用户?我还检查了本地存储库 .git/config 中的文件 -> 根本没有有关电子邮件的信息。
最佳答案
git config --list --show-origin
此命令将向您显示所有配置选项以及设置该选项的每个文件的位置。
来自docs :
When reading, the values are read from the system, global and repository local configuration files by default, and options --system, --global, --local, --worktree and --file can be used to tell the command to read from only that location (see FILES).
...
ENVIRONMENT
GIT_CONFIG
Take the configuration from the given file instead of .git/config. Using the "--global" option forces this to ~/.gitconfig. Using the "--system" option forces this to $(prefix)/etc/gitconfig.
关于git - git 如何解析 user.email 和密码来验证用户身份?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57713114/