Multiple Git Users On Same Machine

懵懂的女人 提交于 2020-06-11 01:08:53

问题


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?


回答1:


If you don't have enough disk space for separate clones, you can try the following:

Use differente logins and write a script that changes the username and email on login.

OR (if you really want to use one account only)

Write a script that asks after every login for the username and email. That way nobody can forget to change the username and email.




回答2:


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!



来源:https://stackoverflow.com/questions/18845874/multiple-git-users-on-same-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!