Set git credentials based on folder

cbutler picture cbutler · May 31, 2018 · Viewed 7.8k times · Source

Is it possible to have a folder that contains multiple repos use one set of credentials and have another folder user a different account? For example I would like to have one folder on my mac for work repos and one folder for personal and have the git username and password automatically switch based on which folder I am in.

Answer

Vikas Yadav picture Vikas Yadav · May 31, 2018

Configuring git config for specific folders is too easy. You can achieve that using just two git commands. Just enter the directory you want git account info to be changed for and do this:

git config --local user.email "[email protected]"

git config --local user.name "yourName"

I think this will help.

Cheers!