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.
1. Identity is commit metadata
Section titled “1. Identity is commit metadata”The two main settings are:
user.nameuser.emailWhen 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 commitThese 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.
3. Configure a default identity
Section titled “3. Configure a default identity”Set a default identity for the current operating-system user:
git config --global user.name "Yousef Ahmed"git config --global user.email "personal@example.com"Inspect the effective values and their sources:
git config --get --show-scope --show-origin user.namegit config --get --show-scope --show-origin user.emailUse the name by which collaborators should recognize you. user.name is not a
GitHub username and does not need to be unique.
4. Override identity for one repository
Section titled “4. Override identity for one repository”A company project may require a company email while personal projects use a personal address:
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:
git config --get --show-scope --show-origin user.emailThis is especially useful when one machine is used for personal and company work.
5. Author and committer
Section titled “5. Author and committer”A commit can record two identities:
Author = the person who originally created the changeCommitter = the person who created this version of the commitFor 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:
git log --format=fuller6. 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 emailnew commit → new configured emailChanging existing commit metadata requires rewriting history. That is a separate, potentially disruptive operation and should not be done casually on shared history.
7. Private commit addresses
Section titled “7. Private commit addresses”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:
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.
8. Practical verification
Section titled “8. Practical verification”Use a disposable repository to verify what a commit records:
git init identity-labcd identity-labgit config --local user.name "Training User"git config --local user.email "training@example.com"After creating a small commit, inspect it:
git log --format=fullergit config --get --show-scope --show-origin user.emailThe log shows the identity copied into the commit. The configuration command shows the value that a future commit would use now.
9. Common mistakes
Section titled “9. Common mistakes”- Assuming
user.nameis 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
noreplyaddress instead of copying the provided address. - Forgetting that attribution rules can differ between hosting providers.
10. Summary
Section titled “10. Summary”user.name and user.email = identity metadata for new commitsGit = creates commits locallyhosting platform = associates stored email with an accountAuthor = original creator of the changeCommitter = creator of the current commit objectlocal identity = overrides global identity in one repository11. Knowledge check
Section titled “11. Knowledge check”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.