Using same git repository by multiple users

谁说胖子不能爱 提交于 2019-12-10 10:37:10

问题


As far as I know, only a single user's identity may be specified with git config. I have a situation where I'd like to have multiple identities for the same git repository, depending on the UNIX user.

The repository is at /var/www. When user jack makes a commit to it, the commit should automatically be jack's identity. When user jill makes a commit, jill's identity should be used.

The reason why I want to use the same repository is because it's the content of a website, and Apache is looking in /var/www. The contents are NOT user-specific, so using Apache's userdir feature is not an option here.


回答1:


Every UNIX user has its own home directory.
Therefore, every UNIX user can have its own git config file (~/.gitconfig).
Then, every UNIX user can commit on shared repository with their own identity.




回答2:


A good way of doing this is by setting the user his email inside the .git/config file for a particular git repository as follows:

    git config user.name "Your Name Here"
    git config user.email your@email.com


来源:https://stackoverflow.com/questions/31583954/using-same-git-repository-by-multiple-users

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