Reputation: 23139
I discovered that I haven't configured the user.name
variable in Git: git config user.name
prints nothing (also with --system
or --global
or --local
).
My full name is also not contained in the output of env
, only my login name, which is different.
Nonetheless, all my commits are attributed to my real first and last name.
How does Git know it?
Clarifications:
My full name is contained in the GIT_COMMITTER_IDENT
and GIT_AUTHOR_IDENT
variables shown by the git var -l
command. (I guess my question would then be: How did it get there?)
I'm talking about a local repository. However I have other repositories on the same computer which are cloned at Github.
I'm using a Debian system.
My full name is contained in the output of getent passwd
.
Upvotes: 3
Views: 807
Reputation: 23139
Unless specified in the Git configuration or in environment variables, Git will try to look up the username in the password file. The lookup is performed in the fmt_ident
function.
Upvotes: 2
Reputation:
It might be the case that you have environment variables set:
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.
Source: https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables
Upvotes: 3