EGit and multiple “users” on same machine

南楼画角 提交于 2019-12-12 17:03:51

问题


I'd like to work with multiple git-based open source projects from the same machine. For each project, I'd like to associate a differnet user.name and user.email as appropriate. For instance, I might want to work on some project called fizz that is hosted on GitHub, and also work on another project called buzz that has its own privately-hosted, centralized git server/repo.

For the fizz project, I'd like to use myname@example.com as my email, so that when I push changes to the master branch, other collaborators see that as my username/email.

But for the buzz project, I'd like to user myname@someotherdomain.example.com, so that when I push changes to its master, collaborators on the buzz project so that as my email.

Unless I'm mistaken, EGit seems to only allow me to configure 1 user.name and user.email. How can I get around this? Thanks in advance!


回答1:


Git configuration is stored in the following files, and when looking up configuration, it is tried in the following order (see git config):

  1. Local: .git/config in the current repository
  2. Global: .gitconfig in the user's home directory
  3. System: gitconfig in the system configuration directory (e.g. /etc on Linux)

So to configure user.email differently for a specific repository, do the following:

  1. Open the properties of a repository from the Git Repositories view
  2. In the Configuration tab, click on Add Entry...
  3. Enter user.email as the key and the desired value
  4. Click OK

The repository configuration can also be changed from the preferences > Team > Git > Configuration > Repository Settings.

Note that in Git, user.name should be a real full name such as Jane Doe.



来源:https://stackoverflow.com/questions/19032708/egit-and-multiple-users-on-same-machine

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