简体   繁体   English

git commit忽略全局配置中的电子邮件,而是使用主机名

[英]git commit ignoring email in global config and using hostname instead

I have an issue similar to this where my laptop was using me<my_emal> for commits, laptop catastrophically died, got new laptop, reinstalled Wheezy, stuck old drive in new laptop and my commits now use me<local_hostname> 我有一个与此类似的问题,其中我的笔记本电脑正在使用me<my_emal>进行提交,笔记本电脑灾难性地死了,换了新笔记本电脑,重新安装了Wheezy,旧驱动器卡在了新笔记本电脑中,现在我的提交使用了me<local_hostname>

My git config has the entries 我的git配置有条目

[user]
name = me
email = myemail

I have tried the command 我已经尝试过命令

print_env

but GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL are not set. 但未设置GIT_AUTHOR_NAMEGIT_AUTHOR_EMAIL

Of the suggested commands 在建议的命令中

git config --system -l
git config --global -l
git config --local -l

only --global has user.name and user.email set and it is correct, --system reports /etc/gitconfig does not exist and --local has no entries for user* ie no user/email entries in my-repo/.git/config only in ~/.gitconfig . 只有--globaluser.nameuser.email设置,这是正确的, --system报告/etc/gitconfig不存在, --local有没有条目user*即在没有用户/电子邮件条目my-repo/.git/config仅在~/.gitconfig

 grep -R GIT_AUTHOR_EMAIL / 2>/dev/null

returns a bunch of results but does not explicitly set it to hostname 返回一堆结果,但未将其显式设置为hostname

As a result this now breaks my building using git-buildpackage as the key to use is me<my_email> not me<hostname> . 结果,这现在使用git-buildpackage破坏了我的建筑,因为要使用的密钥是me<my_email>而不是me<hostname>

I also spotted this on the package building side (which led me to the above post) but that's only for after the commit. 我还在软件包构建方面发现了这一点 (这导致我进入上面的文章),但这仅适用于提交之后。

Running out of ideas now. 现在用完了主意。

Setting null string in local repository is not valid 在本地存储库中设置空字符串无效

Hi, my case was your special case. 嗨,我的案子是你的特例。 (Please be tolerant if this answer was not you intended.) (如果这个答案不是您想要的,请宽容。)

Prerequisite 条件

(OS X 10.10.5, git version 2.5.4 (Apple Git-61)/git version 2.7.0 from Homebrew)

Settings 设置

The local repository had only null string like bellow! 本地存储库只有像null一样的空字符串! In this case, GIT_AUTHOR_IDENT set to `id -F`<`logname`@`hostname`> (I thought old git version 1.9 or so was effective with this configuration though) 在这种情况下,GIT_AUTHOR_IDENT设置为`id -F`<`logname`@`hostname`> (我认为旧的git版本1.9或以上对这种配置有效)

localrepo/.config localrepo /的.config

[user]
name = ""
email = ""

$HOME/.config $ HOME /的.config

[user]
name = me
email = myemail

Intention 意向

I didn't want to log user.email. 我不想登录user.email。 and user.name. 和user.name。

Maybe what you said 也许你说的

no entries for user* ie no user/email entries in my-repo/.git/config only in ~/.gitconfig 没有用户*条目,即my-repo / .git / config中只有〜/ .gitconfig中没有用户/电子邮件条目

is actually like above? 真的像上面吗?

Solution

localrepo/.config localrepo /的.config

[user]
name = " "
email = " "

A space was effective to achieve my intention. 一个空间有效地实现了我的意图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM