Git Username and Email Address Configuration

Git is one of the most popular version control systems which works locally or in a distributed way. Multiple developers or testers can use a single repository for commits, tags, updates, etc. Every user commit is identified with its username and email address. The Git configuration is used to set and use the current user username and email address. In this tutorial, we examine how to set username and email address for the single repository or for all repositories for Git. Every commit contains the username and email address of the committer or reviewer.

Set Username (For Current Repository)

The username is used by a user uniquely for the Git repository. The git config command is used with the user.name option and the username as parameter to set the username for the current repository. In the following example, we set the username for the current repository.

$ git config user.name "İsmail Baydan"

Set Email Address (For Current Repository)

The email address information about the developer is very important for communication about codes, commits, or updates. the user email address can be set for the current repository where this email address is put for all commits made by this user. The git config command is used with the user.email option and the email address to set the current user email address. This email address configuration is set for the current repository only.

$ git config user.email "[email protected]"

Set Username Globally (For All Repositories)

Up to now, we have set the username for a specific single repository. But if we work with multiple repositories in a dynamic way and set the username for all those repositories with a single command we can use the global Git configuration to set username globally. The git config command is used with --global option and user.name option with the username.

$ git config --global user.name "İsmail Baydan"

Set Email Address Globally (For All Repositories)

The email address configuration can be also set globally where the specified email address is used for all repositories located in the current system. The git config command is used with the --global option and user.email option providing the global email address configuration.

$ git config --global user.email "[email protected]"

Display Git Username and Email Address Configuration

The current global username and email address configuration can be listed with the git config command using the --list option like below. The whole Git configuration is displayed with the user.name and user.email configurations like below.

$ git config --list
user.name=İsmail Baydan
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/nmap/nmap.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
Display Git Username and Email Address Configuration

Leave a Comment