18 September 2023

Git get/set name and email

Here's how to get/set email/name that is being used in by git. Running the below will return the email/name that is used globally.
git config --global --get user.email
git config --global --get user.name
You can update the email/name by using the below.
git config --global user.email global@email.com
git config --global user.name "This is global"
Note: The global config file can be found in the home directory: ~/.gitconfig

Switch into a repository. Running the below will return the email/name that is used by that repository.

git config --get user.email
git config --get user.name
The repository will used the global email/name. In order to use a different email/name for this repository, you can use the below to change it.
git config user.email local@email.com
git config user.name "This is local"
The email/name will be stored in your repository's config: path_to_repository/.git/config You can also manually update this by adding the below directly into path_to_repository/.git/config
[user]
name = "This is local"
email = local@email.com

No comments:

Post a Comment