Skip Navigation

Scott Spence

How to Configure Git Username and Email

2 min read
Hey! Thanks for stopping by! Just a word of warning, this post is about 2 years old, . If there's technical information in here it's more than likely out of date.

The Git username and email are the bare minimum needed for when working with Git to commit changes. It’s also one of the first things you do after installing Git.

The username and email are used to set the author of commits. Version control wouldn’t be much use if you didn’t know who to blame for the changes that broke production. 😂

Set Global Git Username and Email

Using git config there’s a few commands to get started. First check to see if there is any config already in place with the --list flag.

git config --list

ℹ️ To leave the --list view in the terminal use the q key to quit the view.

You can set the global username and email for Git with the git config command and the --global flag.

The config here is presuming the use of GitHub where the name can be the GitHub username and the email the email associated with the GitHub username.

git config --global yourGitHubUserName
git config --global [email protected]
git config --list

ℹ️ To leave the --list view in the terminal use the q key to quit the view.

The git config changes are saved to the home directory of the user to a .gitconfig file. I’m using Linux so I can access it with a text editor and point to the home path ~ and edit it with a text editor like nano.

nano ~/.gitconfig

That will show me the current settings, which is currently only the user details.

ℹ️ To leave the view in nano use the Ctrl+x to exit.

        name = yourGitHubUserName
        email = [email protected]

Set Git Username and Email for a Specific Repository

When would you want to do this? Say you have a different username and email that may have been assigned to you for working on a specific project.

This is when it is handy to set the username and email for a specific project.

To do that, change directory to the project and use the same Git config commands without the --global flag.

cd my-project-im-working-on
git config yourMaybeAssignedUsername
git config [email protected]

This will set the username and email for this specific project.


The Git username and email can be set using git config and the --global flag, when needed specific user details can be set per repository when inside the project directory and omitting the --global flag.

There's a reactions leaderboard you can check out too.

Copyright © 2017 - 2024 - All rights reserved Scott Spence