How to Set Your Git Username and Email

Git records a name and email address in each commit to identify its author. Configure these values before committing, either for every repository on your computer or for one repository only. This guide also explains how to verify the settings and fix the “author identity unknown” error.

Practice Git workflows →

Set your Git name and email globally

Use --global to set the default identity for your operating-system user. Replace the example values with the name and email you want recorded in future commits:

git config --global user.name "Alex Morgan"
git config --global user.email "alex@example.com"

These values identify commits; they are not your Git hosting username or password. If you want commits linked to your hosting profile, use an email address the provider recognizes, such as a verified address or its supplied private email address.

Set a different identity for one repository

To use another identity only in the current repository, first change into that repository and omit --global:

git config user.name "Work Name"
git config user.email "work@example.com"

Repository-local values override global values inside that repository. This is useful for separating work and personal identities. Check the directory with git rev-parse --show-toplevel before setting a local value so you do not configure a neighboring project by mistake.

Check which Git identity will be used

Display the effective values for the current repository:

git config user.name
git config user.email

To see all configured values and where they come from, including repository, global, and system settings, run:

git config --list --show-origin

Fix “Author identity unknown”

Git cannot create a commit when it has no configured author name or email. Set both values at the appropriate scope, then verify them:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config user.name
git config user.email

If the error occurs in just one repository, a repository-specific setting may be more appropriate. If the displayed values are unexpected, use git config --list --show-origin to identify which configuration file supplies them.

Change or remove a Git username or email

Set a new value using the same scope where the old value was configured. To remove a repository-local value and fall back to the global setting:

git config --unset user.name
git config --unset user.email

To remove a global value instead, add --global to git config --unset. If a setting has multiple entries, Git may report that more than one value exists; inspect the config list and remove the specific unwanted entry rather than deleting configuration files wholesale.

Does changing the config update old commits?

No. Git uses the configured name and email when creating new commits. Changing the setting does not rewrite existing commits. Changing commit history requires a separate history rewrite and can affect collaborators if those commits have already been shared. Confirm the author before creating a commit if the identity matters for a work or personal repository.

Frequently asked questions

Is git user.name the same as my GitHub username?

No. user.name is the author name written into commits. It can be different from your username on GitHub or another host.

Should I use --global or repository-only settings?

Use --global for your usual identity across repositories. Use repository-only settings when a specific project needs a different author identity or when you want to avoid changing other projects.

Learn Git Faster by Practicing

Reading is just the first step. Real learning happens when you practice.

Start Learning Git →