我可以在.gitconfig中为自己指定多个用户吗? [英] Can I specify multiple users for myself in .gitconfig?

查看:392
本文介绍了我可以在.gitconfig中为自己指定多个用户吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

〜/ .gitconfig 中,我在 [user] 下列出了我的个人电子邮件地址,因为这就是我想用Github回购。

In my ~/.gitconfig, I list my personal email address under [user], since that's what I want to use for Github repos.

但是,我最近也开始使用git进行工作。我公司的git repo允许我提交,但是当它发出新变更集的公告时,它表示它们来自Anonymous,因为它无法识别我的 .gitconfig - 至少,这是我的理论。

But, I've recently started using git for work, too. My company's git repo allows me to commit, but when it sends out announcements of new changesets, it says they are from Anonymous because it doesn't recognize the email address in my .gitconfig - at least, that's my theory.

是否可以在<$中指定多个 [user] C $ C>的.gitconfig ?或者是否有其他方法来覆盖某个目录的默认 .gitconfig ?在我的例子中,我查看了〜/ worksrc / 中的所有工作代码 - 是否有一种方法来指定 .gitconfig 仅用于该目录(及其子目录)?

Is it possible to specify multiple [user] definitions in .gitconfig? Or is there some other way to override the default .gitconfig for a certain directory? In my case, I check out all work code in ~/worksrc/ - is there a way to specify a .gitconfig for only that directory (and its subdirectories)?

推荐答案

您可以配置单个回购以使用特定用户/电子邮件地址这会覆盖全局配置。从repo的根目录运行

You can configure an individual repo to use a specific user / email address which overrides the global configuration. From the root of the repo, run

git config user.name "Your Name Here"
git config user.email your@email.com

而默认用户/电子邮件配置在〜/ .gitconfig

whereas the default user / email is configured in your ~/.gitconfig

git config --global user.name "Your Name Here"
git config --global user.email your@email.com

这篇关于我可以在.gitconfig中为自己指定多个用户吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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