Git - How to create project specific config?

Override global git configuration with project specific configuration

Suppose you are working for two different companies and you want to commit code with different credentials i.e. user name and user email. Git commit will by default pick the configuration from your home directory ~/.gitconfig

How To Override Credentials For Project

To override setting for project you should navigate to desired directory on terminal and set configuration individually as follows specific to your project

  git config user.email "gulshan.saini@gmail.com"
  git config user.name "Gulshan Saini"

To confirm the changes, execute below commands on terminal

  git config user.email // Output: gulshan.saini@gmail.com
  git config user.name  // Output: Gulshan Saini

Bonus Tip You can view complete list of local configuration using below command

  git config --local --list

git