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.
- Per Project – Here git will store username and password in the local directory (.git/config)
- Per-user – Here config will be stored in the user’s home directory (~/.gitconfig)
- System wise – Here config will be stored in the specific directory that all user can access (/etc/gitconfig)
git config user.name "Your project user name" git config user.email "[email protected]"
git config --global user.name "Your username" git config --global user.email "[email protected]"
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. 🙂