How to Configure Git Username and Email Address

Updated on

2 min read

Set Git Username and Email Address

Git is a distributed version control system that helps developers and engineers keep track of changes they make to their code.

The first thing you should do before starting to use Git on your system is to configure your Git username and email address. Git associates your identity with every commit you make.

Git allows you to set a global and per-project username and email address. You can set or change your git identity using the git config command. The changes made will only apply to future commits. The name and email associated with the commits you made before the change are unaffected.

Setting Global Git Username and Email

The global git username and email address are associated with the commits on all repositories on your system that don’t have repository-specific values.

To set your global commit name and email address, run the git config command with the --global option:

git config --global "Your Name"git config --global ""

Once done, you can verify that the information is correctly set by executing the following command:

git config --list Name

The command saves the values in the global configuration file, ~/.gitconfig:

    name = Your Name
    email =

You can also edit the file with your text editor, but it is recommended to use the git config command.

Setting Git Username and Email for a Single Repository

Sometimes, you may need to use a different username or email address for a specific repository. In that case, to set the identity, run the git config command without the --global option from within the repository directory.

Let’s assume you want to set a repository-specific username and email address for a repository located in the ~/Code/myapp directory. First, switch the repository root directory:

cd ~/Code/myapp

Set a Git username and email address:

git config "Your Name"git config ""

Verify that the changes were made correctly:

git config --list Name

The repository-specific settings are stored in the .git/config, located in the root directory of the repository.


The Git username and email address can be set with the git config command. The values are associated with your commits.

If you are new to Git, read the Pro Git book , which is an excellent resource for learning about how to use Git.

Leave a comment below if you hit a problem or have feedback.