EGit和多个“用户”在同一台机器上 [英] EGit and multiple "users" on same machine

查看:158
本文介绍了EGit和多个“用户”在同一台机器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一台机器上使用多个基于git的开源项目。对于每个项目,我想根据需要关联不同的 user.name user.email 。例如,我可能想要在GitHub上托管的一些名为 fizz 的项目上工作,也可以在另一个名为 buzz 有自己的私人托管,集中的git服务器/ repo。



对于 fizz 项目,我想使用 myname@example.com 作为我的电子邮件,所以当我将更改推送到主分支时,其他协作者将其视为我的用户名/电子邮件。 / p>

但是对于 buzz 项目,我想使用 myname@someotherdomain.example .com ,所以当我将更改推送到其主人时,协作者在 buzz 项目中,以便作为我的电子邮件。



除非我错了,EGit似乎只允许我配置1 user.name user.email 。我该怎么办?感谢提前!

解决方案

Git配置存储在以下文件中,当查找配置时,将在以下尝试订单(请参阅 git config ):


  1. 本地: .git / config 在当前存储库中

  2. 全局:<$ c $系统配置目录中的用户主目录

  3. 系统: gitconfig 中的.gitconfig / etc 在Linux上)

所以要配置 user.email 对于特定的存储库,请执行以下操作:


  1. 从存储库的属性中打开
  2. >
  3. 输入 user.email 作为键和所需值

  4. 单击确定

Th e库配置也可以从首选项>团队> Git>配置>存储库设置更改。



请注意,在Git中, user.name 应该是一个真正的全名,如 Jane Doe


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!

解决方案

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.

这篇关于EGit和多个“用户”在同一台机器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆