Multiple Git Users Setup on Same Machine

gitmulti-user

Our team shares a MacBook which everybody uses from time to time with one account on it, so we're all on the some login. To commit our code changes we're using SmartGitHg 4.5 (current Git version installed is 1.8.3.2). Since these commits can get a little messy, I'm looking for a setup/config solution to commit under the right name, because if I leave the userdata in Git's global config empty, I'm automatically committing under the name 'developer' (which is the account name of our machine) even though I'm always getting asked for credentials when committing/pushing.

So maybe someone has a good idea how to set this up so that one just has to put in the credentials when committing/pushing/pulling. Maybe using the OSX keychain could be a way?

Best Answer

Make a repository clone for each developer on mac, and set user.name and user.email config variable for each clone (project level property). So, in this case each developer have to use own project (just different directories).

To set project level property execute (current directory should be the root of the project):

git config user.name "User Name"
git config user.email "UserEmail@Host"

UPDATE Also if the only reason you are using the same login for different developers is disk space, you can create one clone in /Users/Shared/, configure user.name and user.email variables in $HOME/.gitconfig and voila!

Related Question