git - 为什么 Git 在没有配置的情况下知道我的名字?

标签 git configuration

我发现我还没有在 Git 中配置 user.name 变量:git config user.name 不打印任何内容(还有 --system--global--local).

我的全名也没有包含在 env 的输出中,只有我的登录名,这是不同的。

尽管如此,我所有的提交都归因于我的真实名字和姓氏。

Git 是怎么知道的?


说明:

  • 我的全名包含在 git var -l 命令显示的 GIT_COMMITTER_IDENTGIT_AUTHOR_IDENT 变量中。 (我想我的问题是:它是如何到达那里的?)

  • 我说的是本地存储库。但是,我在同一台计算机上有其他存储库,这些存储库是在 Github 上克隆的。

  • 我使用的是 Debian 系统。

  • 我的全名包含在 getent passwd 的输出中。

最佳答案

可能是您设置了环境变量:

The final creation of a Git commit object is usually done by git-commit-tree, which uses these environment variables as its primary source of information, falling back to configuration values only if these aren’t present.

GIT_AUTHOR_NAME is the human-readable name in the “author” field.

GIT_AUTHOR_EMAIL is the email for the “author” field.

GIT_AUTHOR_DATE is the timestamp used for the “author” field.

GIT_COMMITTER_NAME sets the human name for the “committer” field.

GIT_COMMITTER_EMAIL is the email address for the “committer” field.

GIT_COMMITTER_DATE is used for the timestamp in the “committer” field.

EMAIL is the fallback email address in case the user.email configuration value isn’t set. If this isn’t set, Git falls back to the system user and host names.

来源:https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables

关于git - 为什么 Git 在没有配置的情况下知道我的名字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40244336/

相关文章:

java - 将提交者/作者添加到 NetBeans 11.0 Bitbucket 提交

css - Git add -patch...但忽略空格更改

android - .gitignore 不适用于 .cxx 文件夹

configuration - 您将如何从 ClearCase 的特定分支中选择版本?

tomcat - 添加外部配置文件时配置设置是否被替换?

java - 如何开发在部署时请求数据库凭据的 Java Web 服务?

Git:如何在存储库之间移动分支

git - 当我 'git push' 时,git 钩子(Hook)是否被推送到远程?

apache .htaccess 仅向经过身份验证的用户显示目录索引

c# - .Net Core - IConfigurationRoot 读取整个 json 文件