THE GITHTML FIELD GUIDE
Set the correct Git author name and email
Set user.name and user.email to the identity you want recorded in future commits. Use repository-local configuration when work and personal projects need different identities; use global configuration only for a suitable default. These values are commit metadata, not GitHub login credentials, and changing them does not rewrite existing commits.
Choose identity and scope intentionally
A commit can include an author and a committer, each with a name and email. For ordinary local commits these often match, but imported or replayed changes can differ. The identity is stored in repository history, so use an address that is appropriate for the project’s audience and your privacy requirements. A display name need not be the GitHub account’s username.
Repository-local configuration overrides a global default for that checkout. This is useful on a computer used for both employer and personal work. If you use a GitHub-provided privacy address, copy the exact address from your account settings rather than inventing its format. Account association and privacy controls are separate from Git’s ability to write the metadata.
Set and inspect the effective values
Run local configuration inside the intended repository. The example identity is deliberately fictional and must be replaced. Inspect the source of the effective settings if the result differs from expectations; conditional includes, environment variables, or command-level overrides can complicate a machine with several identities. Never paste an access token into user.email.
- Choose --global only when the value should be the default across repositories for this operating-system user.
- Before a sensitive first push, inspect a new commit’s author and committer metadata to confirm the intended address was recorded.
git config --local user.name "Example Contributor"
git config --local user.email "contributor@example.com"
git config --show-origin --get user.name
git config --show-origin --get user.emailSeparate future configuration from past history
Changing configuration affects later commits. It does not repair an already published email address, alter repository permissions, or make an authentication failure disappear. If an unpublished last commit has the wrong identity, assess a focused amendment separately. Rewriting shared history requires coordination and is not a routine response to a harmless display-name difference.
For authentication problems, inspect the remote protocol and credential mechanism instead. HTTPS credentials and SSH keys answer who may access the server; user.name and user.email answer what identity is recorded in a commit. Keeping these concerns separate avoids a common loop of changing author metadata while the real problem is an expired credential, the wrong account, or missing repository access. Finish by checking both the effective settings and the next recorded commit rather than assuming the configuration command alone proves the result.
On a shared workstation, verify whose operating-system account owns the global settings. A convenient machine-wide default can otherwise put the wrong identity on unrelated projects.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.