如何让git为给定的项目使用正确的标识(名称和电子邮件)? [英] How to tell git to use the correct identity (name and email) for a given project?

查看:149
本文介绍了如何让git为给定的项目使用正确的标识(名称和电子邮件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用我的个人笔记本电脑进行工作和个人项目,我想使用我的工作电子邮件地址来提交我的工作提交(gitolite)和我的个人电子邮件地址(github)。



我阅读了以下解决方案,它们都是全局或临时的:


  • git config --global user.emailbob@example.com

  • git config user.emailbob @ example。 com

  • git commit --authorBob< bob@example.com>

  • 设置其中一个 GIT_AUTHOR_EMAIL GIT_COMMITTER_EMAIL EMAIL 环境变量



一个解决方案是手动运行一个shell函数,将我的环境设置为工作 个人 ,但我很确定我经常忘记切换到正确的身份,导致在错误的身份下提交。



是否有绑定某个代表的方法? ository,项目名称等,以一个身份(姓名,电子邮件)?人们做什么?

解决方案

git config user.emailbob@example.com code>



在回购库中执行该操作将会在THAT回购库中设置配置,而不是在全局范围内。



看起来,这很像你所追求的,除非我误读你。


I use my personal laptop for both work and personal projects and I would like to use my work email address for my commits at work (gitolite) and my personal email address for the rest (github).

I read about the following solutions which are all either global or temporary:

  • git config --global user.email "bob@example.com"
  • git config user.email "bob@example.com"
  • git commit --author "Bob <bob@example.com>"
  • setting one of the GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL or EMAIL environment variables

One solution is to run manually a shell function that sets my environment to work or personal, but I am pretty sure that I will often forget to switch to the correct identity resulting in committing under the wrong identity.

Is there a way of binding a certain repository, project name, etc. to an identity (name, email)? What do people do?

解决方案

git config user.email "bob@example.com"

Doing that one inside a repo will set the configuration on THAT repo, and not globally.

Seems like that's pretty much what you're after, unless I'm misreading you.

这篇关于如何让git为给定的项目使用正确的标识(名称和电子邮件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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