Skip to content

Identity

Every commit records an identity. Git needs that identity to describe who created the change, but it does not obtain it automatically from GitHub, GitLab, or another hosting service.

The two main settings are:

user.name
user.email

When Git creates a commit, their effective values become part of the commit’s metadata:

user.name + user.email
↓
author and committer metadata in the new commit

These values are not login credentials and do not prove a person’s identity. Git accepts the configured strings as metadata. Commit signing is a separate topic.

2. Git is independent from hosting platforms

Section titled “2. Git is independent from hosting platforms”

Git creates commits locally and works without an account on a hosting service. It cannot assume that a developer uses only one provider or one account.

A hosting platform later reads the email stored in a pushed commit. If that email is associated with an account, the platform can attribute the commit to that account. An unassociated email does not invalidate the commit; it only affects platform attribution.

Set a default identity for the current operating-system user:

Terminal window
git config --global user.name "Yousef Ahmed"
git config --global user.email "personal@example.com"

Inspect the effective values and their sources:

Terminal window
git config --get --show-scope --show-origin user.name
git config --get --show-scope --show-origin user.email

Use the name by which collaborators should recognize you. user.name is not a GitHub username and does not need to be unique.

A company project may require a company email while personal projects use a personal address:

Terminal window
git config --local user.name "Yousef Ahmed"
git config --local user.email "yousef@company.com"

The local values override the global defaults only in that repository. Other repositories continue to use the global identity unless they have their own overrides.

Check the current repository before creating a commit:

Terminal window
git config --get --show-scope --show-origin user.email

This is especially useful when one machine is used for personal and company work.

A commit can record two identities:

Author = the person who originally created the change
Committer = the person who created this version of the commit

For an ordinary commit created directly by one developer, both identities are normally the same. They can differ when one person applies another person’s patch, or when an operation recreates a commit while preserving its original author.

Inspect both identities and their dates:

Terminal window
git log --format=fuller

6. Changing configuration does not rewrite old commits

Section titled “6. Changing configuration does not rewrite old commits”

Identity is copied into a commit when that commit is created. Changing the configuration affects future commits only:

old commit → old configured email
new commit → new configured email

Changing existing commit metadata requires rewriting history. That is a separate, potentially disruptive operation and should not be done casually on shared history.

A commit email is visible in repository history. Hosting platforms may provide a private commit address, often called a noreply address. Use the exact address shown in the account’s email settings:

Terminal window
git config --global user.email "YOUR_PLATFORM_PROVIDED_PRIVATE_ADDRESS"

The platform-provided address is already associated with that platform account. An invented look-alike address will not be attributed automatically.

For commits created in a website interface, the platform selects the configured web commit address. For commits created on a computer, local Git uses the effective user.email value. Enabling privacy on a website does not change the local configuration automatically.

A private address from one provider may not be recognized by another provider. Check attribution settings when the same repository is hosted in several places.

Use a disposable repository to verify what a commit records:

Terminal window
git init identity-lab
cd identity-lab
git config --local user.name "Training User"
git config --local user.email "training@example.com"

After creating a small commit, inspect it:

Terminal window
git log --format=fuller
git config --get --show-scope --show-origin user.email

The log shows the identity copied into the commit. The configuration command shows the value that a future commit would use now.

  • Assuming user.name is a hosting-platform username.
  • Treating the commit email as an authentication credential.
  • Changing a website profile and expecting local configuration to change.
  • Using a company email globally and leaking it into personal projects.
  • Assuming new configuration rewrites old commits.
  • Inventing a noreply address instead of copying the provided address.
  • Forgetting that attribution rules can differ between hosting providers.
user.name and user.email = identity metadata for new commits
Git = creates commits locally
hosting platform = associates stored email with an account
Author = original creator of the change
Committer = creator of the current commit object
local identity = overrides global identity in one repository
1. Does Git copy your display name automatically from GitHub?

No. Git uses the effective local configuration when it creates a commit.

2. Does an unrecognized email make a commit invalid?

No. The commit remains valid in Git, but a hosting platform may not attribute it to the intended account.

3. When can the author and committer differ?

They can differ when one person records another person’s change or when an operation recreates a commit while preserving the original author.

4. Does changing user.email update earlier commits?

No. The new value affects future commits. Existing commits keep the metadata stored when they were created.