问题
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