James Hiew
James Hiew

Reputation: 7157

Git commits are not using the repository-configured `user.name` value

I have a repository where I've configured a local user.name and user.email. I've verified this as running git config user.name and git config user.email within the git repo gives the right outputs, and my .git/config file shows them correctly as well - but my commits still use my global user.name (although they do use the correct local user.email). I am running macOS 10.13.4 and Git 2.17.1 - the issue happens both with command-line git and committing from IntelliJ. What could be the issue?

Upvotes: 0

Views: 72

Answers (1)

torek
torek

Reputation: 489588

If git config user.name prints the correct name but git commit does not use that name, something must be overriding the configured value.

The obvious (cough) candidate is an environment variable, as listed in the top level git command manual page, most of the way to the end. You can do a quick test whether this is the case using the git var command:

$ git var GIT_AUTHOR_IDENT | sed 's/@/ /'
Chris Torek <chris.torek gmail.com> 1528489689 -0700

vs:

$ GIT_AUTHOR_NAME='A U Thor' [email protected] git var GIT_AUTHOR_IDENT
A U Thor <[email protected]> 1528489743 -0700

This shows how I overwrote the name and email address that would have come out, had I not set these environment variables.

Upvotes: 0

Related Questions