EGit和多个“用户”在同一台机器上

编程入门 行业动态 更新时间:2024-10-28 20:19:30
本文介绍了EGit和多个“用户”在同一台机器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想在同一台机器上使用多个基于git的开源项目。对于每个项目,我想根据需要关联不同的 user.name 和 user.email 。例如,我可能想要在GitHub上托管的一些名为 fizz 的项目上工作,也可以在另一个名为 buzz 有自己的私人托管,集中的git服务器/ repo。

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

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

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

解决方案

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

  • 本地: .git / config 在当前存储库中
  • 全局:<$ c $系统配置目录中的用户主目录
  • 系统: gitconfig 中的.gitconfig / etc 在Linux上)
  • 所以要配置 user.email 对于特定的存储库,请执行以下操作:

  • 从存储库的属性中打开
  • >
  • 输入 user.email 作为键和所需值
  • 单击确定
  • 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 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, 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):

  • Local: .git/config in the current repository
  • Global: .gitconfig in the user's home directory
  • 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:

  • Open the properties of a repository from the Git Repositories view
  • In the Configuration tab, click on Add Entry...
  • Enter user.email as the key and the desired value
  • 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和多个“用户”在同一台机器上

    本文发布于:2023-10-20 03:50:34,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1509753.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:多个   用户   在同一   机器上   EGit

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!