How to tell git to use the correct identity (name and email) for a given project? How to tell git to use the correct identity (name and email) for a given project? git git

How to tell git to use the correct identity (name and email) for a given project?


git config user.email "bob@example.com"

Doing that one inside a repo will set the configuration on THAT repo, and not globally.

Seems like that's pretty much what you're after, unless I'm misreading you.


You need to use the local set command below:

local set

git config user.email mahmoud@company.cccgit config user.name 'Mahmoud Zalt'

local get

git config --get user.emailgit config --get user.name

The local config file is in the project directory: .git/config.

global set

git config --global user.email mahmoud@zalt.megit config --global user.name 'Mahmoud Zalt'

global get

git config --global --get user.emailgit config --global --get user.name

The global config file in in your home directory: ~/.gitconfig.

Remember to quote blanks, etc, for example: 'FirstName LastName'


Edit the config file with in ".git" folder to maintain the different username and email depends upon the repository

  • Go to Your repository
  • Show the hidden files and go to ".git" folder
  • Find the "config" file
  • Add the below lines at EOF

[user]

name = Bob

email = bob@example.com

This below command show you which username and email set for this repository.

git config --get user.name

git config --get user.email

Example: for mine that config file in D:\workspace\eclipse\ipchat\.git\config

Here ipchat is my repo name