How to configure username and email in git?

So you have different projects for your clients, boss, or personal playground that you want to track via git. The code repositories are most likely different also. You want to configure a different user per project or certain projects. So how to configure username and email in git that will meet all your needs?

It is very easy. Git offers 3 ways for this.

  1. Per Project – Here git will store username and password in the local directory (.git/config)
  2. Per-user – Here config will be stored in the user’s home directory (~/.gitconfig)
  3. System wise – Here config will be stored in the specific directory that all user can access (/etc/gitconfig)

 

Per Project

git config user.name "Your project user name"
git config user.email "[email protected]"

 Per User

git config --global user.name "Your username"
git config --global user.email "[email protected]"

 System wise

git config --system user.name "Your default name"
git config --system user.email "[email protected]"

By the way, I am assuming you are using a Mac when describing the file location. 🙂

cheers!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.